Édition de catégorie.
This commit is contained in:
parent
2215fbc9d7
commit
0dafa938e8
4 changed files with 26 additions and 2 deletions
|
@ -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/<int:pk>',
|
||||
EditCategory.as_view(),
|
||||
name='category-edit',
|
||||
)
|
||||
]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
<tr>
|
||||
<td><a href="{{c.get_absolute_url}}">{{c.name}}</a></td>
|
||||
<td>{{c.content_set.count}}</td>
|
||||
<td><a class="btn btn-primary btn-sm" href="">
|
||||
<td><a class="btn btn-primary btn-sm" href="{% url "content:category-edit" c.pk %}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
Éditer
|
||||
</a>
|
||||
<a class="btn btn-danger btn-sm" title="Supprimer" href="{% url "content:category-delete" c.id %}">
|
||||
<a class="btn btn-danger btn-sm" title="Supprimer" href="{% url "content:category-delete" c.pk %}">
|
||||
<i class="glyphicon glyphicon-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
|
|
7
templates/edit.html
Normal file
7
templates/edit.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Mettre à jour" />
|
||||
</form>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue