3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-11-29 16:12:26 +00:00

Merge branch 'activateUser' into dev

Close #10
This commit is contained in:
Yoann Pétri 2018-12-23 21:44:20 +01:00
commit b4b88b1dba
4 changed files with 20 additions and 0 deletions

View file

@ -76,6 +76,9 @@
<span class="tabulation"><a href="">Ajouter aux superusers</a></span> <span class="tabulation"><a href="">Ajouter aux superusers</a></span>
{% endif %} {% endif %}
{% 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> </li>
</ul> </ul>
</div> </div>

View file

@ -17,6 +17,9 @@
<tr> <tr>
<th>Utilisateur</th> <th>Utilisateur</th>
<th>Profil</th> <th>Profil</th>
{% if perms.auth.change_user %}
<th>Activer / Désactiver</th>
{% endif %}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -24,6 +27,9 @@
<tr> <tr>
<td>{{ user }}</td> <td>{{ user }}</td>
<td><a class="button small" href="{% url 'users:profile' user.pk %}">Profil</a></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> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View file

@ -44,4 +44,5 @@ urlpatterns = [
path('allConsumptions/<int:pk>/<int:page>', views.all_consumptions, name="allConsumptions"), path('allConsumptions/<int:pk>/<int:page>', views.all_consumptions, name="allConsumptions"),
path('allMenus/<int:pk>/<int:page>', views.all_menus, name="allMenus"), path('allMenus/<int:pk>/<int:page>', views.all_menus, name="allMenus"),
path('exportCSV', views.export_csv, name="exportCSV"), path('exportCSV', views.export_csv, name="exportCSV"),
path('switchActivateUser/<int:pk>', views.switch_activate_user, name="switchActivateUser"),
] ]

View file

@ -487,6 +487,16 @@ def all_menus(request, pk, page):
menus = paginator.get_page(page) menus = paginator.get_page(page)
return render(request, "users/all_menus.html", {"menus": menus, "user":user}) 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 ########## ########## Groups ##########
@active_required @active_required