From 0dafa938e80dcd2222bf6ec16cd015ee8037989f Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 30 Jan 2018 23:04:06 +0100 Subject: [PATCH] =?UTF-8?q?=C3=89dition=20de=20cat=C3=A9gorie.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/urls.py | 6 ++++++ content/views.py | 11 +++++++++++ settings/templates/settings/settings.html | 4 ++-- templates/edit.html | 7 +++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 templates/edit.html 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 %}