8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 01:16:27 +00:00

Add gros kikimètre

This commit is contained in:
chirac 2016-11-01 03:11:32 +01:00
parent a4d3100512
commit 826d700478
5 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,19 @@
{% 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 %}

View file

@ -3,5 +3,7 @@
{% block sidebar %} {% block sidebar %}
{% if is_cableur %} {% if is_cableur %}
<p><a href="{% url "logs:stats-models" %}">Statistiques base de donnée</a></p> <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 %} {% endif %}
{% endblock %} {% endblock %}

View file

@ -0,0 +1,12 @@
{% 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 %}

View file

@ -6,4 +6,6 @@ urlpatterns = [
url(r'^$', views.index, name='index'), url(r'^$', views.index, name='index'),
url(r'^revert_action/(?P<revision_id>[0-9]+)$', views.revert_action, name='revert-action'), 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_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'),
] ]

View file

@ -12,6 +12,7 @@ from django.contrib.auth.decorators import login_required, permission_required
from django.db.models import ProtectedError from django.db.models import ProtectedError
from django.forms import ValidationError from django.forms import ValidationError
from django.db import transaction from django.db import transaction
from django.db.models import Count
from reversion.models import Revision from reversion.models import Revision
from reversion.models import Version from reversion.models import Version
@ -94,5 +95,28 @@ def stats_models(request):
'port' : [Port.PRETTY_NAME, Port.objects.count()], 'port' : [Port.PRETTY_NAME, Port.objects.count()],
'chambre' : [Room.PRETTY_NAME, Room.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}) 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})