From 3e244b8ba9f4d375d8fa139e203bba72420ff372 Mon Sep 17 00:00:00 2001 From: Grizzly Date: Sun, 17 Jun 2018 13:12:12 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20bouton=20pour=20supprimer=20les?= =?UTF-8?q?=20acc=C3=A9s=20gracieux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/templates/users/aff_whitelists.html | 3 +++ users/urls.py | 3 +++ users/views.py | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/users/templates/users/aff_whitelists.html b/users/templates/users/aff_whitelists.html index 099d4b39..01a9efdd 100644 --- a/users/templates/users/aff_whitelists.html +++ b/users/templates/users/aff_whitelists.html @@ -47,6 +47,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ whitelist.date_start }} {{ whitelist.date_end }} + {% can_delete whitelist %} + {% include 'buttons/suppr.html' with href='users:del-whitelist' id=whitelist.id %} + {% acl_end %} {% can_edit whitelist %} {% include 'buttons/edit.html' with href='users:edit-whitelist' id=whitelist.id %} {% acl_end %} diff --git a/users/urls.py b/users/urls.py index 23193983..724601c3 100644 --- a/users/urls.py +++ b/users/urls.py @@ -62,6 +62,9 @@ urlpatterns = [ url(r'^edit_whitelist/(?P[0-9]+)$', views.edit_whitelist, name='edit-whitelist'), + url(r'^del_whitelist/(?P[0-9]+)$', + views.del_whitelist, + name='del-whitelist'), url(r'^add_school/$', views.add_school, name='add-school'), url(r'^edit_school/(?P[0-9]+)$', views.edit_school, diff --git a/users/views.py b/users/views.py index 3cc568a8..fcb44f65 100644 --- a/users/views.py +++ b/users/views.py @@ -478,6 +478,23 @@ def edit_whitelist(request, whitelist_instance, **_kwargs): ) +@login_required +@can_delete(Whitelist) +def del_whitelist(request, whitelist, **_kwargs): + """ Supprime un acces gracieux""" + if request.method == "POST": + whitelist.delete() + messages.success(request, "L'accés gracieux a été supprimé") + return redirect(reverse( + 'users:profil', + kwargs={'userid': str(whitelist.user.id)} + )) + return form( + {'objet': whitelist, 'objet_name': 'whitelist'}, + 'users/delete.html', + request + ) + @login_required @can_create(School) def add_school(request):