From b03e37e7e600d79d999c3079010b5d92517b9b34 Mon Sep 17 00:00:00 2001 From: chirac Date: Tue, 1 Nov 2016 04:03:58 +0100 Subject: [PATCH] Fluidifie le code --- logs/templates/logs/aff_stats_users.html | 10 ++++++---- logs/views.py | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/logs/templates/logs/aff_stats_users.html b/logs/templates/logs/aff_stats_users.html index 08418fde..4570fd97 100644 --- a/logs/templates/logs/aff_stats_users.html +++ b/logs/templates/logs/aff_stats_users.html @@ -1,10 +1,11 @@ - {% for key, stats in stats_list.items %} + {% for key_dict, stats_dict in stats_list.items %} + {% for key, stats in stats_dict.items %} -

Statistiques par utilisateur de {{ key }}

+

Statistiques par {{ key_dict }} de {{ key }}

- - + + @@ -17,3 +18,4 @@ {% endfor %}
UtilisateurNombre d'objets de l'utilisateur{{ key_dict }}Nombre de {{ key }} par {{ key_dict }} Rang
{% endfor %} + {% endfor %} diff --git a/logs/views.py b/logs/views.py index 0acbf9a6..072b4efc 100644 --- a/logs/views.py +++ b/logs/views.py @@ -106,13 +106,22 @@ def stats_models(request): @permission_required('cableur') def stats_users(request): stats = { + 'Utilisateur' : { 'Machines' : User.objects.annotate(num=Count('machine')).order_by('-num')[:10], 'Facture' : User.objects.annotate(num=Count('facture')).order_by('-num')[:10], 'Bannissement' : User.objects.annotate(num=Count('ban')).order_by('-num')[:10], 'Accès gracieux' : User.objects.annotate(num=Count('whitelist')).order_by('-num')[:10], - 'Etablissements' : School.objects.annotate(num=Count('user')).order_by('-num')[:10], - 'Moyen de paiment' : Paiement.objects.annotate(num=Count('facture')).order_by('-num')[:10], - 'Banque' : Banque.objects.annotate(num=Count('facture')).order_by('-num')[:10], + 'Droits' : User.objects.annotate(num=Count('right')).order_by('-num')[:10], + }, + 'Etablissement' : { + 'Utilisateur' : School.objects.annotate(num=Count('user')).order_by('-num')[:10], + }, + 'Moyen de paiement' : { + 'Utilisateur' : Paiement.objects.annotate(num=Count('facture')).order_by('-num')[:10], + }, + 'Banque' : { + 'Utilisateur' : Banque.objects.annotate(num=Count('facture')).order_by('-num')[:10], + }, } return render(request, 'logs/stats_users.html', {'stats_list': stats}) @@ -120,6 +129,8 @@ def stats_users(request): @permission_required('cableur') def stats_actions(request): stats = { + 'Utilisateur' : { 'Action' : User.objects.annotate(num=Count('revision')).order_by('-num')[:40], + }, } return render(request, 'logs/stats_users.html', {'stats_list': stats})