Commit 826d7004 authored by chirac's avatar chirac

Add gros kikimètre

parent a4d31005
{% for key, stats in stats_list.items %}
<table class="table table-striped">
<h4>Statistiques par utilisateur de {{ key }}</h4>
<thead>
<tr>
<th>Utilisateur</th>
<th>Nombre d'objets de l'utilisateur</th>
<th>Rang</th>
</tr>
</thead>
{% for stat in stats %}
<tr>
<td>{{ stat }}</td>
<td>{{ stat.num }}</td>
<td>{{ forloop.counter }}</td>
</tr>
{% endfor %}
</table>
{% endfor %}
......@@ -3,5 +3,7 @@
{% block sidebar %}
{% if is_cableur %}
<p><a href="{% url "logs:stats-models" %}">Statistiques base de donnée</a></p>
<p><a href="{% url "logs:stats-actions" %}">Statistiques des actions de cablage</a></p>
<p><a href="{% url "logs:stats-users" %}">Statistiques utilisateurs</a></p>
{% endif %}
{% endblock %}
{% extends "logs/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Statistiques par utilisateur{% endblock %}
{% block content %}
<h2>Statistiques par utilisateur</h2>
{% include "logs/aff_stats_users.html" with stats_list=stats_list %}
<br />
<br />
<br />
{% endblock %}
......@@ -6,4 +6,6 @@ urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^revert_action/(?P<revision_id>[0-9]+)$', views.revert_action, name='revert-action'),
url(r'^stats_models/$', views.stats_models, name='stats-models'),
url(r'^stats_users/$', views.stats_users, name='stats-users'),
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
]
......@@ -12,6 +12,7 @@ from django.contrib.auth.decorators import login_required, permission_required
from django.db.models import ProtectedError
from django.forms import ValidationError
from django.db import transaction
from django.db.models import Count
from reversion.models import Revision
from reversion.models import Version
......@@ -94,5 +95,28 @@ def stats_models(request):
'port' : [Port.PRETTY_NAME, Port.objects.count()],
'chambre' : [Room.PRETTY_NAME, Room.objects.count()],
},
'Actions effectuées sur la base' :
{
'revision' : ["Nombre d'actions", Revision.objects.count()],
},
}
return render(request, 'logs/stats_models.html', {'stats_list': stats})
@login_required
@permission_required('cableur')
def stats_users(request):
stats = {
'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],
}
return render(request, 'logs/stats_users.html', {'stats_list': stats})
@login_required
@permission_required('cableur')
def stats_actions(request):
stats = {
'Action' : User.objects.annotate(num=Count('revision')).order_by('-num')[:40],
}
return render(request, 'logs/stats_users.html', {'stats_list': stats})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment