diff --git a/content/urls.py b/content/urls.py index f12c853..2b3da7d 100644 --- a/content/urls.py +++ b/content/urls.py @@ -4,6 +4,7 @@ from .views import ( ContentCategoryList, CreateCategory, DeleteCategory, + EditCategory, ) app_name = 'content' @@ -23,4 +24,9 @@ urlpatterns = [ CreateCategory.as_view(), name='category-new' ), + path( + 'category/edit/', + EditCategory.as_view(), + name='category-edit', + ) ] diff --git a/content/views.py b/content/views.py index a8d114c..28253e6 100644 --- a/content/views.py +++ b/content/views.py @@ -23,11 +23,22 @@ class ContentCategoryList(generic.ListView): context['category'] = category return context + class CreateCategory(generic.CreateView): + """Création de catégorie.""" model = Category fields = '__all__' + class DeleteCategory(generic.DeleteView): + """Suppression de catégorie""" model = Category success_url = reverse_lazy('settings:index') template_name = "confirm_delete.html" + + +class EditCategory(generic.UpdateView): + """Édition de catégorie.""" + model = Category + fields = '__all__' + template_name = "edit.html" diff --git a/settings/templates/settings/settings.html b/settings/templates/settings/settings.html index 9097390..bab1f25 100644 --- a/settings/templates/settings/settings.html +++ b/settings/templates/settings/settings.html @@ -16,11 +16,11 @@ {{c.name}} {{c.content_set.count}} - + Éditer - + diff --git a/templates/edit.html b/templates/edit.html new file mode 100644 index 0000000..9e38274 --- /dev/null +++ b/templates/edit.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% block content %} +
{% csrf_token %} + {{ form.as_p }} + +
+{% endblock %}