Commit 787e048a authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

More stats

parent 3fc6c725
......@@ -30,6 +30,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="glyphicon glyphicon-stats"></i>
Évènements
</a>
<a class="list-group-item list-group-item-info" href="{% url "logs:stats-general" %}">
<i class="glyphicon glyphicon-stats"></i>
Général
</a>
<a class="list-group-item list-group-item-info" href="{% url "logs:stats-models" %}">
<i class="glyphicon glyphicon-stats"></i>
Base de données
......
......@@ -27,6 +27,7 @@ from . import views
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_general/$', views.stats_general, name='stats-general'),
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'),
......
......@@ -93,9 +93,34 @@ def revert_action(request, revision_id):
return redirect("/logs/")
return form({'objet': revision, 'objet_name': revision.__class__.__name__ }, 'logs/delete.html', request)
@login_required
@permission_required('cableur')
def stats_general(request):
all_active_users = User.objects.filter(state=User.STATE_ACTIVE)
ip = dict()
for ip_range in IpType.objects.all():
all_ip = IpList.objects.filter(ip_type=ip_range)
used_ip = Interface.objects.filter(ipv4__in=all_ip).count()
ip[ip_range] = [ip_range, all_ip.count(), used_ip, all_ip.count()-used_ip]
stats = [
[["Categorie", "Nombre d'utilisateurs"], {
'active_users' : ["Users actifs", User.objects.filter(state=User.STATE_ACTIVE).count()],
'inactive_users' : ["Users désactivés", User.objects.filter(state=User.STATE_DISABLED).count()],
'archive_users' : ["Users archivés", User.objects.filter(state=User.STATE_ARCHIVE).count()],
'adherent_users' : ["Adhérents à l'association", len([user for user in all_active_users if user.is_adherent()])],
'connexion_users' : ["Utilisateurs bénéficiant d'une connexion", len([user for user in all_active_users if user.has_access()])],
'ban_users' : ["Utilisateurs bannis", len([user for user in all_active_users if user.is_ban()])],
'whitelisted_user' : ["Utilisateurs bénéficiant d'une connexion gracieuse", len([user for user in all_active_users if user.is_whitelisted()])],
}],
[["Range d'ip", "Nombre d'ip totales", "Nombre d'ip utilisées", "Nombre d'ip libres"] ,ip]
]
return render(request, 'logs/stats_general.html', {'stats_list': stats})
@login_required
@permission_required('cableur')
def stats_models(request):
all_active_users = User.objects.filter(state=User.STATE_ACTIVE)
stats = {
'Users' : {
'users' : [User.PRETTY_NAME, User.objects.count()],
......
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