From c75c204d8d1498bea73a48f128c4598d30019312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Mon, 30 Oct 2017 19:29:29 +0000 Subject: [PATCH 01/27] Fix : un user n'est plus cotisant si fin de cotis > now --- templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index f536c9ff..3d8cfea7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -155,7 +155,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Adhésion - {% if request_user.end_adhesion != None %} + {% if request_user.is_adherent %} jusqu'au {{ request_user.end_adhesion|date:"d b Y" }} {% else %} Non adhérent From 0ed60c64fd55d14a194e54f448dfe9474f775291 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 30 Oct 2017 20:53:49 +0100 Subject: [PATCH 02/27] =?UTF-8?q?Cas=20o=C3=B9=20il=20n'y=20a=20pas=20d'ip?= =?UTF-8?q?v4=20sur=20machine=20active,=20on=20assigne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freeradius_utils/auth.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 8f2a6f8a..16f3f084 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -247,6 +247,9 @@ def check_user_machine_and_register(nas_type, username, mac_address): return (False, u"Machine enregistrée sur le compte d'un autre user...", '') elif not interface.is_active: return (False, u"Machine desactivée", '') + elif not interface.ipv4: + interface.assign_ipv4() + return (True, u"Ok, Reassignation de l'ipv4", user.pwd_ntlm) else: return (True, u"Access ok", user.pwd_ntlm) elif nas_type: @@ -324,9 +327,14 @@ def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address): return (sw_name, u'Access Ok, Capture de la mac...' + extra_log, DECISION_VLAN) else: return (sw_name, u'Erreur dans le register mac %s' % reason + unicode(mac_address), VLAN_NOK) - elif not interface.first().is_active: - return (sw_name, u'Machine non active / adherent non cotisant', VLAN_NOK) else: - return (sw_name, u'Machine OK' + extra_log, DECISION_VLAN) + interface = interface.first() + if not interface.is_active: + return (sw_name, u'Machine non active / adherent non cotisant', VLAN_NOK) + elif not interface.ipv4: + interface.assign_ipv4() + return (sw_name, u"Ok, Reassignation de l'ipv4" + extra_log, DECISION_VLAN) + else: + return (sw_name, u'Machine OK' + extra_log, DECISION_VLAN) From f8992ca0d87ab0b727d7f9cb52daa59995890b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Wed, 1 Nov 2017 16:01:10 +0000 Subject: [PATCH 03/27] Passage du search en GET + proprification du nom des variables --- search/models.py | 20 +++++----- search/templates/search/search.html | 7 ++-- search/views.py | 57 +++++++++++++---------------- templates/base.html | 3 +- 4 files changed, 40 insertions(+), 47 deletions(-) diff --git a/search/models.py b/search/models.py index 8d1fa0e4..f0900728 100644 --- a/search/models.py +++ b/search/models.py @@ -28,18 +28,18 @@ from django import forms from django.forms import Form from django.forms import ModelForm -CHOICES = ( +CHOICES_USER = ( ('0', 'Actifs'), ('1', 'Désactivés'), ('2', 'Archivés'), ) -CHOICES2 = ( +CHOICES_CO = ( (1, 'Active'), ("", 'Désactivée'), ) -CHOICES3 = ( +CHOICES_AFF = ( ('0', 'Utilisateurs'), ('1', 'Machines'), ('2', 'Factures'), @@ -51,12 +51,12 @@ CHOICES3 = ( class SearchForm(Form): - search_field = forms.CharField(label = 'Search', max_length = 100) + query = forms.CharField(label = 'Search', max_length = 100) class SearchFormPlus(Form): - search_field = forms.CharField(label = 'Search', max_length = 100, required=False) - filtre = forms.MultipleChoiceField(label="Filtre utilisateurs", required=False, widget =forms.CheckboxSelectMultiple,choices=CHOICES) - connexion = forms.MultipleChoiceField(label="Filtre connexion", required=False, widget =forms.CheckboxSelectMultiple,choices=CHOICES2) - affichage = forms.MultipleChoiceField(label="Filtre affichage", required=False, widget =forms.CheckboxSelectMultiple,choices=CHOICES3) - date_deb = forms.DateField(required=False, label="Date de début", help_text='DD/MM/YYYY', input_formats=['%d/%m/%Y']) - date_fin = forms.DateField(required=False, help_text='DD/MM/YYYY', input_formats=['%d/%m/%Y'], label="Date de fin") + query = forms.CharField(label = 'Search', max_length = 100, required=False) + user_state = forms.MultipleChoiceField(label="Filtre utilisateurs", required=False, widget =forms.CheckboxSelectMultiple,choices=CHOICES_USER) + co_state = forms.MultipleChoiceField(label="Filtre connexion", required=False, widget =forms.CheckboxSelectMultiple,choices=CHOICES_CO) + aff = forms.MultipleChoiceField(label="Filtre affichage", required=False, widget =forms.CheckboxSelectMultiple,choices=CHOICES_AFF) + start = forms.DateField(required=False, label="Date de début", help_text='DD/MM/YYYY', input_formats=['%d/%m/%Y']) + end = forms.DateField(required=False, help_text='DD/MM/YYYY', input_formats=['%d/%m/%Y'], label="Date de fin") diff --git a/search/templates/search/search.html b/search/templates/search/search.html index adb5dd92..f97af015 100644 --- a/search/templates/search/search.html +++ b/search/templates/search/search.html @@ -28,11 +28,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Recherche{% endblock %} {% block content %} -{% bootstrap_form_errors searchform %} +{% bootstrap_form_errors search_form %} -
- {% csrf_token %} - {% bootstrap_form searchform %} + + {% bootstrap_form search_form %} {% bootstrap_button "Search" button_type="submit" icon="search" %}

diff --git a/search/views.py b/search/views.py index 16c365d8..34421ac1 100644 --- a/search/views.py +++ b/search/views.py @@ -40,36 +40,31 @@ from cotisations.models import Facture from search.models import SearchForm, SearchFormPlus from preferences.models import GeneralOption -def form(ctx, template, request): - c = ctx - c.update(csrf(request)) - return render(request, template, c) - -def search_result(search, type, request): - date_deb = None - date_fin = None - states=[] - co=[] - aff=[] +def search_result(search_form, type, request): + start = None + end = None + user_state = [] + co_state = [] + aff = [] if(type): - aff = search.cleaned_data['affichage'] - co = search.cleaned_data['connexion'] - states = search.cleaned_data['filtre'] - date_deb = search.cleaned_data['date_deb'] - date_fin = search.cleaned_data['date_fin'] + aff = search_form.cleaned_data['aff'] + co_state = search_form.cleaned_data['co_state'] + user_state = search_form.cleaned_data['user_state'] + start = search_form.cleaned_data['start'] + end = search_form.cleaned_data['end'] date_query = Q() if aff==[]: aff = ['0','1','2','3','4','5','6'] - if date_deb != None: - date_query = date_query & Q(date__gte=date_deb) - if date_fin != None: - date_query = date_query & Q(date__lte=date_fin) - search = search.cleaned_data['search_field'] + if start != None: + date_query = date_query & Q(date__gte=start) + if end != None: + date_query = date_query & Q(date__lte=end) + search = search_form.cleaned_data['query'] query1 = Q() - for s in states: + for s in user_state: query1 = query1 | Q(state = s) - connexion = [] + connexion = [] recherche = {'users_list': None, 'machines_list' : [], 'facture_list' : None, 'ban_list' : None, 'white_list': None, 'port_list': None, 'switch_list': None} @@ -121,14 +116,14 @@ def search_result(search, type, request): @login_required def search(request): - search = SearchForm(request.POST or None) - if search.is_valid(): - return form(search_result(search, False, request), 'search/index.html',request) - return form({'searchform' : search}, 'search/search.html', request) + search_form = SearchForm(request.GET or None) + if search_form.is_valid(): + return render(request, 'search/index.html', search_result(search_form, False, request)) + return render(request, 'search/search.html', {'search_form' : search_form}) @login_required def searchp(request): - search = SearchFormPlus(request.POST or None) - if search.is_valid(): - return form(search_result(search, True, request), 'search/index.html',request) - return form({'searchform' : search}, 'search/search.html', request) + search_form = SearchFormPlus(request.GET or None) + if search_form.is_valid(): + return render(request, 'search/index.html', search_result(search_form, True, request)) + return render(request, 'search/search.html', {'search_form' : search_form}) diff --git a/templates/base.html b/templates/base.html index 3d8cfea7..0e8c6187 100644 --- a/templates/base.html +++ b/templates/base.html @@ -72,8 +72,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endif %}