Commit 6f3fc983 authored by Hugo LEVY-FALK's avatar Hugo LEVY-FALK

Suppression de superuser

parent d2946a94
...@@ -58,7 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc., ...@@ -58,7 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% for user in superuser_right %} {% for user in superuser_right %}
<li class="list-group-item col-xs-12 col-sm-6 col-md-4" style="border:none;"> <li class="list-group-item col-xs-12 col-sm-6 col-md-4" style="border:none;">
{{user}} {{user}}
<a role="button" href="" title="{{ desc|default:"Supprimer" }}"> <a role="button" href="{% url 'users:del-superuser' %}" title="{{ desc|default:"Supprimer" }}">
<i class="fa fa-times" style="color:red"></i> <i class="fa fa-times" style="color:red"></i>
</a> </a>
</li> </li>
...@@ -43,6 +43,9 @@ urlpatterns = [ ...@@ -43,6 +43,9 @@ urlpatterns = [
url(r'^del_group/(?P<userid>[0-9]+)/(?P<listrightid>[0-9]+)$', url(r'^del_group/(?P<userid>[0-9]+)/(?P<listrightid>[0-9]+)$',
views.del_group, views.del_group,
name='del-group'), name='del-group'),
url(r'^new_serviceuser/$', views.new_serviceuser, name='new-serviceuser'), url(r'^new_serviceuser/$', views.new_serviceuser, name='new-serviceuser'),
url(r'^edit_serviceuser/(?P<serviceuserid>[0-9]+)$', url(r'^edit_serviceuser/(?P<serviceuserid>[0-9]+)$',
views.edit_serviceuser, views.edit_serviceuser,
...@@ -294,6 +294,16 @@ def del_group(request, user, listrightid, **_kwargs): ...@@ -294,6 +294,16 @@ def del_group(request, user, listrightid, **_kwargs):
return HttpResponseRedirect(request.META.get('HTTP_REFERER')) return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
@can_edit(User, 'groups')
def del_superuser(request, user, **_kwargs):
"""Remove the superuser right of an user."""
user.is_superuser = False
messages.success(request, "%s n'est plus superuser" % user)
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
@login_required @login_required
@can_create(ServiceUser) @can_create(ServiceUser)
def new_serviceuser(request): def new_serviceuser(request):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment