mirror of
https://github.com/nanoy42/coope
synced 2024-12-24 16:03:47 +00:00
commit
b4b88b1dba
4 changed files with 20 additions and 0 deletions
|
@ -76,6 +76,9 @@
|
|||
<span class="tabulation"><a href="">Ajouter aux superusers</a></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if perms.auth.change_user %}
|
||||
<span class="tabulation"><a href="{% url 'users:switchActivateUser' user.pk %}">{{ user.is_active | yesno:"Désa,A"}}ctiver</a></span>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
<tr>
|
||||
<th>Utilisateur</th>
|
||||
<th>Profil</th>
|
||||
{% if perms.auth.change_user %}
|
||||
<th>Activer / Désactiver</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -24,6 +27,9 @@
|
|||
<tr>
|
||||
<td>{{ user }}</td>
|
||||
<td><a class="button small" href="{% url 'users:profile' user.pk %}">Profil</a></td>
|
||||
{% if perms.auth.change_user %}
|
||||
<td><a class="button small" href="{% url 'users:switchActivateUser' user.pk %}">{{ user.is_active | yesno:"Désa,A"}}ctiver</a></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -44,4 +44,5 @@ urlpatterns = [
|
|||
path('allConsumptions/<int:pk>/<int:page>', views.all_consumptions, name="allConsumptions"),
|
||||
path('allMenus/<int:pk>/<int:page>', views.all_menus, name="allMenus"),
|
||||
path('exportCSV', views.export_csv, name="exportCSV"),
|
||||
path('switchActivateUser/<int:pk>', views.switch_activate_user, name="switchActivateUser"),
|
||||
]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue