diff --git a/users/templates/users/users_index.html b/users/templates/users/users_index.html
index 176ad57..7cc5545 100644
--- a/users/templates/users/users_index.html
+++ b/users/templates/users/users_index.html
@@ -17,6 +17,9 @@
Utilisateur |
Profil |
+ {% if perms.auth.change_user %}
+ Activer / Désactiver |
+ {% endif %}
@@ -24,6 +27,9 @@
{{ user }} |
Profil |
+ {% if perms.auth.change_user %}
+ {{ user.is_active | yesno:"Désa,A"}}ctiver |
+ {% endif %}
{% endfor %}
diff --git a/users/urls.py b/users/urls.py
index aa83e43..2201cae 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -44,4 +44,5 @@ urlpatterns = [
path('allConsumptions//', views.all_consumptions, name="allConsumptions"),
path('allMenus//', views.all_menus, name="allMenus"),
path('exportCSV', views.export_csv, name="exportCSV"),
+ path('switchActivateUser/', views.switch_activate_user, name="switchActivateUser"),
]
diff --git a/users/views.py b/users/views.py
index c60daa7..4f277e7 100644
--- a/users/views.py
+++ b/users/views.py
@@ -487,6 +487,16 @@ def all_menus(request, pk, page):
menus = paginator.get_page(page)
return render(request, "users/all_menus.html", {"menus": menus, "user":user})
+@active_required
+@login_required
+@permission_required('auth.change_user')
+def switch_activate_user(request, pk):
+ user = get_object_or_404(User, pk=pk)
+ user.is_active = 1 - user.is_active
+ user.save()
+ messages.success(request, "Le statut de l'utilisateur a bien été changé")
+ return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
+
########## Groups ##########
@active_required