From 9d79ffb5ca00d28fe552647335a0a496e479a7ee Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 3 May 2018 14:08:05 +0200 Subject: [PATCH] =?UTF-8?q?Plus=20de=20B=C3=94T=C3=89=20dans=20l'affichage?= =?UTF-8?q?=20des=20superusers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logs/templates/logs/aff_stats_droits.html | 6 +++++- logs/views.py | 9 +++++++-- users/forms.py | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/logs/templates/logs/aff_stats_droits.html b/logs/templates/logs/aff_stats_droits.html index bf672b67..6e424223 100644 --- a/logs/templates/logs/aff_stats_droits.html +++ b/logs/templates/logs/aff_stats_droits.html @@ -66,7 +66,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,

{{utilisateur.last}}

{% endif %} + {% if droit != 'Superuser' %} + {% else %} + + {% endif %} @@ -79,4 +83,4 @@ with this program; if not, write to the Free Software Foundation, Inc., -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/logs/views.py b/logs/views.py index afb0a118..0acd4bd9 100644 --- a/logs/views.py +++ b/logs/views.py @@ -41,7 +41,7 @@ from django.urls import reverse from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.decorators import login_required -from django.db.models import Count, Max +from django.db.models import Count, Max, F from reversion.models import Revision from reversion.models import Version, ContentType @@ -469,9 +469,14 @@ def stats_droits(request): for droit in ListRight.objects.all().select_related('group_ptr'): stats_list[droit] = droit.user_set.all().annotate( num=Count('revision'), - last=Max('revision__date_created') + last=Max('revision__date_created'), ) + stats_list['Superuser'] = User.objects.filter(is_superuser=True).annotate( + num=Count('revision'), + last=Max('revision__date_created'), + ) + return render( request, 'logs/stats_droits.html', diff --git a/users/forms.py b/users/forms.py index f939c6cd..17170058 100644 --- a/users/forms.py +++ b/users/forms.py @@ -457,7 +457,7 @@ class GroupForm(FormRevMixin, ModelForm): class Meta: model = User - fields = ['groups', 'is_superuser'] + fields = ['is_superuser', 'groups'] def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__)