8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 20:03:11 +00:00

Fluidifie le code

This commit is contained in:
chirac 2016-11-01 04:03:58 +01:00
parent 64f035ec4b
commit b03e37e7e6
2 changed files with 20 additions and 7 deletions

View file

@ -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 %}
<table class="table table-striped"> <table class="table table-striped">
<h4>Statistiques par utilisateur de {{ key }}</h4> <h4>Statistiques par {{ key_dict }} de {{ key }}</h4>
<thead> <thead>
<tr> <tr>
<th>Utilisateur</th> <th>{{ key_dict }}</th>
<th>Nombre d'objets de l'utilisateur</th> <th>Nombre de {{ key }} par {{ key_dict }}</th>
<th>Rang</th> <th>Rang</th>
</tr> </tr>
</thead> </thead>
@ -17,3 +18,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endfor %} {% endfor %}
{% endfor %}

View file

@ -106,13 +106,22 @@ def stats_models(request):
@permission_required('cableur') @permission_required('cableur')
def stats_users(request): def stats_users(request):
stats = { stats = {
'Utilisateur' : {
'Machines' : User.objects.annotate(num=Count('machine')).order_by('-num')[:10], 'Machines' : User.objects.annotate(num=Count('machine')).order_by('-num')[:10],
'Facture' : User.objects.annotate(num=Count('facture')).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], 'Bannissement' : User.objects.annotate(num=Count('ban')).order_by('-num')[:10],
'Accès gracieux' : User.objects.annotate(num=Count('whitelist')).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], 'Droits' : User.objects.annotate(num=Count('right')).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], '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}) return render(request, 'logs/stats_users.html', {'stats_list': stats})
@ -120,6 +129,8 @@ def stats_users(request):
@permission_required('cableur') @permission_required('cableur')
def stats_actions(request): def stats_actions(request):
stats = { stats = {
'Utilisateur' : {
'Action' : User.objects.annotate(num=Count('revision')).order_by('-num')[:40], 'Action' : User.objects.annotate(num=Count('revision')).order_by('-num')[:40],
},
} }
return render(request, 'logs/stats_users.html', {'stats_list': stats}) return render(request, 'logs/stats_users.html', {'stats_list': stats})