diff --git a/users/templates/users/aff_bans.html b/users/templates/users/aff_bans.html index 2e3957a1..f9b11455 100644 --- a/users/templates/users/aff_bans.html +++ b/users/templates/users/aff_bans.html @@ -47,6 +47,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ ban.date_start }} {{ ban.date_end }} + {% can_delete ban %} + {% include 'buttons/suppr.html' with href='users:del-ban' id=ban.id %} + {% acl_end %} {% can_edit ban %} {% include 'buttons/edit.html' with href='users:edit-ban' id=ban.id %} {% acl_end %} diff --git a/users/urls.py b/users/urls.py index 5d868196..23193983 100644 --- a/users/urls.py +++ b/users/urls.py @@ -55,6 +55,7 @@ urlpatterns = [ name='del-serviceuser'), url(r'^add_ban/(?P[0-9]+)$', views.add_ban, name='add-ban'), url(r'^edit_ban/(?P[0-9]+)$', views.edit_ban, name='edit-ban'), + url(r'^del-ban/(?P[0-9]+)$', views.del_ban, name='del-ban'), url(r'^add_whitelist/(?P[0-9]+)$', views.add_whitelist, name='add-whitelist'), diff --git a/users/views.py b/users/views.py index 34a08313..3cc568a8 100644 --- a/users/views.py +++ b/users/views.py @@ -404,6 +404,24 @@ def edit_ban(request, ban_instance, **_kwargs): request ) +@login_required +@can_delete(Ban) +def del_ban(request, ban, **_kwargs): + """ Supprime un banissement""" + if request.method == "POST": + ban.delete() + messages.success(request, "Le banissement a été supprimé") + return redirect(reverse( + 'users:profil', + kwargs={'userid': str(ban.user.id)} + )) + return form( + {'objet': ban, 'objet_name': 'ban'}, + 'users/delete.html', + request + ) + + @login_required @can_create(Whitelist)