- {% include 'buttons/edit.html' with href='users:edit-listright' id=listright.id %}
- {% include 'buttons/history.html' with href='users:history' name='listright' id=listright.id %}
-
-
-
+
+
+
+
+{% endif %}
+{% endfor %}
diff --git a/users/templates/users/index_listright.html b/users/templates/users/index_listright.html
index 57165792..3b8b3e60 100644
--- a/users/templates/users/index_listright.html
+++ b/users/templates/users/index_listright.html
@@ -34,9 +34,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Ajouter un droit ou groupe
{% acl_end %}
Supprimer un ou plusieurs droits/groupes
- {% include "users/aff_listright.html" with listright_list=listright_list %}
-
+ {% include "users/aff_listright.html" %}
{% endblock %}
diff --git a/users/views.py b/users/views.py
index fcb44f65..b427f710 100644
--- a/users/views.py
+++ b/users/views.py
@@ -39,7 +39,7 @@ from django.urls import reverse
from django.shortcuts import get_object_or_404, render, redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
-from django.db.models import ProtectedError
+from django.db.models import ProtectedError, Count, Max
from django.utils import timezone
from django.db import transaction
from django.http import HttpResponse
@@ -806,15 +806,27 @@ def index_shell(request):
@can_view_all(ListRight)
def index_listright(request):
""" Affiche l'ensemble des droits"""
- listright_list = ListRight.objects.order_by('unix_name')\
- .prefetch_related('permissions').prefetch_related('user_set')
- superuser_right = User.objects.filter(is_superuser=True)
+ rights = {}
+ for right in (ListRight.objects
+ .order_by('name')
+ .prefetch_related('permissions')
+ .prefetch_related('user_set')
+ ):
+ rights[right] = (right.user_set
+ .annotate(action_number=Count('revision'),
+ last_seen=Max('revision__date_created'))
+ )
+ superusers = (User.objects
+ .filter(is_superuser=True)
+ .annotate(action_number=Count('revision'),
+ last_seen=Max('revision__date_created'))
+ )
return render(
request,
'users/index_listright.html',
{
- 'listright_list': listright_list,
- 'superuser_right' : superuser_right,
+ 'rights': rights,
+ 'superusers' : superusers,
}
)