diff --git a/cotisations/templates/cotisations/aff_cotisations.html b/cotisations/templates/cotisations/aff_cotisations.html index b73bc107..48a856a2 100644 --- a/cotisations/templates/cotisations/aff_cotisations.html +++ b/cotisations/templates/cotisations/aff_cotisations.html @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} - +
{% if facture_list.paginator %} {% include "pagination.html" with list=facture_list %} {% endif %} @@ -85,4 +85,4 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if facture_list.paginator %} {% include "pagination.html" with list=facture_list %} {% endif %} - +
diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 823d0d58..c20764e9 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -192,19 +192,21 @@ def post_auth(data): mac = data.get('Calling-Station-Id', None) + # Switch et bornes héritent de machine et peuvent avoir plusieurs interfaces filles + nas_machine = nas_instance.machine # Si il s'agit d'un switch - if hasattr(nas_instance, 'switch'): + if hasattr(nas_machine, 'switch'): port = data.get('NAS-Port-Id', data.get('NAS-Port', None)) #Pour les infrastructures possédant des switchs Juniper : #On vérifie si le switch fait partie d'un stack Juniper - instance_stack = nas_instance.switch.stack + instance_stack = nas_machine.switch.stack if instance_stack: # Si c'est le cas, on resélectionne le bon switch dans la stack id_stack_member = port.split("-")[1].split('/')[0] - nas_instance = Interface.objects.filter(switch__in=Switch.objects.filter(stack=instance_stack).filter(stack_member_id=id_stack_member)).select_related('domain__extension').first() + nas_machine = Switch.objects.filter(stack=instance_stack).filter(stack_member_id=id_stack_member).prefetch_related('interface_set__domain__extension').first() # On récupère le numéro du port sur l'output de freeradius. La ligne suivante fonctionne pour cisco, HP et Juniper port = port.split(".")[0].split('/')[-1][-2:] - out = decide_vlan_and_register_switch(nas_instance, nas_type, port, mac) + out = decide_vlan_and_register_switch(nas_machine, nas_type, port, mac) sw_name, room, reason, vlan_id = out log_message = '(fil) %s -> %s [%s%s]' % \ @@ -271,7 +273,7 @@ def check_user_machine_and_register(nas_type, username, mac_address): return (False, u"Machine inconnue", '') -def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address): +def decide_vlan_and_register_switch(nas_machine, nas_type, port_number, mac_address): """Fonction de placement vlan pour un switch en radius filaire auth par mac. Plusieurs modes : - nas inconnu, port inconnu : on place sur le vlan par defaut VLAN_OK @@ -296,12 +298,12 @@ def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address): # Get port from switch and port number extra_log = "" # Si le NAS est inconnu, on place sur le vlan defaut - if not nas: + if not nas_machine: return ('?', u'Chambre inconnue', u'Nas inconnu', VLAN_OK) - sw_name = str(nas) + sw_name = str(nas_machine) - port = Port.objects.filter(switch=Switch.objects.filter(switch_interface=nas), port=port_number).first() + port = Port.objects.filter(switch=Switch.objects.filter(machine_ptr=nas_machine), port=port_number).first() #Si le port est inconnu, on place sur le vlan defaut if not port: return (sw_name, "Chambre inconnue", u'Port inconnu', VLAN_OK) diff --git a/logs/templates/logs/aff_stats_droits.html b/logs/templates/logs/aff_stats_droits.html new file mode 100644 index 00000000..bf672b67 --- /dev/null +++ b/logs/templates/logs/aff_stats_droits.html @@ -0,0 +1,82 @@ +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Gabriel Détraz +Copyright © 2017 Goulven Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load bootstrap3 %} +{% load acl %} + +{% for droit,users in stats_list.items %} +
+
+

+ + {{droit}} + {{users.count}} +

+
+
+
+
+ + + + + + + + + + + + {% for utilisateur in users %} + + + {% if utilisateur.is_adherent %} + + {% elif not utilisateur.end_adhesion %} + + {% else %} + + {% endif %} + + + {% if not utilisateur.last %} + + {% else %} + + {% endif %} + + + {% endfor %} +
PseudoAdhésionDerniere connexionNombre d'actionsDate de la dernière action
{{ utilisateur.pseudo }}

Adhérent

On ne s'en souvient plus...

Plus depuis {{ utilisateur.end_adhesion }}

{{ utilisateur.last_login }}{{ utilisateur.num }}

Jamais

{{utilisateur.last}}

+ + + +
+
+
+
+
+{% endfor %} \ No newline at end of file diff --git a/logs/templates/logs/sidebar.html b/logs/templates/logs/sidebar.html index 0e3048e3..03a4bd73 100644 --- a/logs/templates/logs/sidebar.html +++ b/logs/templates/logs/sidebar.html @@ -51,5 +51,9 @@ with this program; if not, write to the Free Software Foundation, Inc., Utilisateurs + + + Groupes de droit + {% acl_end %} {% endblock %} diff --git a/logs/templates/logs/stats_droits.html b/logs/templates/logs/stats_droits.html new file mode 100644 index 00000000..76c20331 --- /dev/null +++ b/logs/templates/logs/stats_droits.html @@ -0,0 +1,36 @@ +{% extends "logs/sidebar.html" %} +{% comment %} +Re2o est un logiciel d'administration développé initiallement au rezometz. Il +se veut agnostique au réseau considéré, de manière à être installable en +quelques clics. + +Copyright © 2017 Gabriel Détraz +Copyright © 2017 Goulven Kermarec +Copyright © 2017 Augustin Lemesle + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +{% endcomment %} + +{% load bootstrap3 %} + +{% block title %}Statistiques des droits{% endblock %} + +{% block content %} +

Statistiques des droits

+ {% include "logs/aff_stats_droits.html" with stats_list=stats_list %} +
+
+
+ {% endblock %} diff --git a/logs/urls.py b/logs/urls.py index 11009835..98dec281 100644 --- a/logs/urls.py +++ b/logs/urls.py @@ -39,4 +39,5 @@ urlpatterns = [ 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'), + url(r'^stats_droits/$', views.stats_droits, name='stats-droits'), ] diff --git a/logs/views.py b/logs/views.py index 48e52fe0..6ab48706 100644 --- a/logs/views.py +++ b/logs/views.py @@ -42,11 +42,13 @@ from django.shortcuts import render, redirect from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.contrib import messages from django.contrib.auth.decorators import login_required -from django.db.models import Count +from django.db.models import Count, Max from reversion.models import Revision from reversion.models import Version, ContentType +from time import time + from users.models import ( User, ServiceUser, @@ -446,3 +448,15 @@ def stats_actions(request): }, } return render(request, 'logs/stats_users.html', {'stats_list': stats}) + +@login_required +@can_view_app('users') +def stats_droits(request): + """Affiche la liste des droits et les users ayant chaque droit""" + depart=time() + stats_list={} + + for droit in ListRight.objects.all().select_related('group_ptr'): + stats_list[droit]=droit.user_set.all().annotate(num=Count('revision'),last=Max('revision__date_created')) + + return render(request, 'logs/stats_droits.html', {'stats_list': stats_list}) diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index c286fcd6..f6da4165 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -23,11 +23,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} - +
{% if machines_list.paginator %} {% include "pagination.html" with list=machines_list %} {% endif %} + @@ -175,6 +176,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
+