mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 20:03:11 +00:00
More stats
This commit is contained in:
parent
3fc6c725bc
commit
787e048a2a
3 changed files with 30 additions and 0 deletions
|
@ -30,6 +30,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<i class="glyphicon glyphicon-stats"></i>
|
<i class="glyphicon glyphicon-stats"></i>
|
||||||
Évènements
|
Évènements
|
||||||
</a>
|
</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" %}">
|
<a class="list-group-item list-group-item-info" href="{% url "logs:stats-models" %}">
|
||||||
<i class="glyphicon glyphicon-stats"></i>
|
<i class="glyphicon glyphicon-stats"></i>
|
||||||
Base de données
|
Base de données
|
||||||
|
|
|
@ -27,6 +27,7 @@ from . import views
|
||||||
urlpatterns = [
|
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_general/$', views.stats_general, name='stats-general'),
|
||||||
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_users/$', views.stats_users, name='stats-users'),
|
||||||
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
|
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
|
||||||
|
|
|
@ -93,9 +93,34 @@ def revert_action(request, revision_id):
|
||||||
return redirect("/logs/")
|
return redirect("/logs/")
|
||||||
return form({'objet': revision, 'objet_name': revision.__class__.__name__ }, 'logs/delete.html', request)
|
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
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def stats_models(request):
|
def stats_models(request):
|
||||||
|
all_active_users = User.objects.filter(state=User.STATE_ACTIVE)
|
||||||
stats = {
|
stats = {
|
||||||
'Users' : {
|
'Users' : {
|
||||||
'users' : [User.PRETTY_NAME, User.objects.count()],
|
'users' : [User.PRETTY_NAME, User.objects.count()],
|
||||||
|
|
Loading…
Reference in a new issue