from django.urls import path

from webapp import views

urlpatterns = [
    path('', views.IndexListView.as_view(), name='index'),
    path('add', views.ArticleCreateView.as_view(), name='articles_add'),
    path('echo', views.articles.json_echo_view),
    path('<int:id>', views.ArticleDetailView.as_view(), name='articles_detail'),
    path('<int:id>/update', views.ArticleUpdateView.as_view(), name='articles_update'),
    path('<int:id>/delete', views.ArticleDeleteView.as_view(), name='articles_delete'),
    path('<int:article_id>/comments/add', views.CommentCreateView.as_view(), name='comments_add'),
    path(
        '<int:article_id>/comments/<int:comment_id>/update',
        views.CommentUpdateView.as_view(),
        name='comments_update',
    ),
    path(
        '<int:article_id>/comments/<int:comment_id>/delete',
        views.CommentDeleteView.as_view(),
        name='comments_delete',
    ),

    # path('api/', views.articles.index_api_view, name='index_api_view'),
    path('api/', views.articles.articles_create_api_view, name='articles_create_api_view'),
    # path('', views.art.as_view(), name='articles_add'),               # POST
    # path('<int:id>', views.ArticleDetailView.as_view(), name='articles_detail'),    # GET
    # path('<int:id>', views.ArticleUpdateView.as_view(), name='articles_update'),    # PUT PATCH
    # path('<int:id>', views.ArticleDeleteView.as_view(), name='articles_delete'),    # DELETE
]

# Safe URLs: list, detail
# Unsafe URLs: create, update, delete

# list GET /articles/
# create POST /articles/
# detail GET /articles/123
# update PUT/PATCH /articles/123
# delete DELETE /articles/123
