From d7d25e7a03b6f2049c4b274c5e37e07f5486d084 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 2 Oct 2016 22:56:11 +0200 Subject: [PATCH 1/7] Add reversion --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 967cae14..e5788471 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Avec apt (recommandé): * texlive-latex-base (jessie) * texlive-fonts-recommended (jessie) * python3-djangorestframework (stretch) + * python3-django-reversion (stretch) Avec pip3: * django-bootstrap3 (pip install) From 07710725f533b0ef9d48ca3439a4528a01364af2 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 2 Oct 2016 23:22:52 +0200 Subject: [PATCH 2/7] Precision --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e5788471..02dbc353 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,12 @@ Avec pip3: Moteur de db conseillé (mysql), postgresql fonctionne également. Pour mysql, il faut installer : - * mysql-server (jessie) * python3-mysqldb (jessie-backports) +Sur le serveur mysql : + * mysql-server (jessie) + + ## Configuration Le site est prêt a fonctionner, il faut simplement créer la base de donnée (par défaut re2o), et régler les variables présentes dans setting_local.py From e24118d22b3145cdaf95e93d5a51f35310e69ef4 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 2 Oct 2016 23:47:29 +0200 Subject: [PATCH 3/7] erreur --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02dbc353..a495563f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Avec apt (recommandé): * python3-dateutil (jessie-backports) * texlive-latex-base (jessie) * texlive-fonts-recommended (jessie) - * python3-djangorestframework (stretch) + * python3-djangorestframework (jessie) * python3-django-reversion (stretch) Avec pip3: From 331c29a58b7f48c50f6e0743efec3aaff00f4a15 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Oct 2016 21:30:05 +0200 Subject: [PATCH 4/7] Add rezo_rez old uid --- re2o/settings.py | 2 +- users/migrations/0038_user_rezo_rez_uid.py | 19 +++++++++++++++++++ users/models.py | 5 +++-- users/templates/users/aff_users.html | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 users/migrations/0038_user_rezo_rez_uid.py diff --git a/re2o/settings.py b/re2o/settings.py index de49c713..58204747 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP +from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, UID_RANGES BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/users/migrations/0038_user_rezo_rez_uid.py b/users/migrations/0038_user_rezo_rez_uid.py new file mode 100644 index 00000000..6665aae6 --- /dev/null +++ b/users/migrations/0038_user_rezo_rez_uid.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0037_ldapuser_login_shell'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='rezo_rez_uid', + field=models.IntegerField(null=True, blank=True, unique=True), + ), + ] diff --git a/users/models.py b/users/models.py index 63ef614b..e68ebfc2 100644 --- a/users/models.py +++ b/users/models.py @@ -116,6 +116,7 @@ class User(AbstractBaseUser): state = models.IntegerField(choices=STATES, default=STATE_ACTIVE) registered = models.DateTimeField(auto_now_add=True) uid_number = models.IntegerField(default=auto_uid, unique=True) + rezo_rez_uid = models.IntegerField(unique=True, blank=True, null=True) USERNAME_FIELD = 'pseudo' REQUIRED_FIELDS = ['name', 'surname', 'email'] @@ -235,9 +236,9 @@ class User(AbstractBaseUser): def ldap_sync(self, base=True, access_refresh=True, mac_refresh=True): self.refresh_from_db() try: - user_ldap = LdapUser.objects.get(uidNumber=self.id) + user_ldap = LdapUser.objects.get(uidNumber=self.uid_number) except LdapUser.DoesNotExist: - user_ldap = LdapUser(uidNumber=self.id) + user_ldap = LdapUser(uidNumber=self.uid_number) if base: user_ldap.name = self.pseudo user_ldap.sn = self.pseudo diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html index c86efaf5..e113be6d 100644 --- a/users/templates/users/aff_users.html +++ b/users/templates/users/aff_users.html @@ -19,6 +19,7 @@ Prénom Nom Pseudo + Uid Fin de cotisation le Connexion Profil @@ -29,6 +30,7 @@ {{ user.name }} {{ user.surname }} {{ user.pseudo }} + {{ user.uid_number }} {% if user.is_adherent %}{{ user.end_adhesion }}{% else %}Non adhérent{% endif %} {% if user.has_access == True %} Active From 0a847b5a2c49ad2244dcaacaddfb098527415de1 Mon Sep 17 00:00:00 2001 From: Dalahro Date: Fri, 7 Oct 2016 23:40:44 +0200 Subject: [PATCH 5/7] Modification du paginateur Factorisation du machin --- .../templates/cotisations/aff_cotisations.html | 17 +++-------------- machines/models.py | 2 +- machines/serializers.py | 2 +- machines/templates/machines/aff_machines.html | 17 +++-------------- machines/urls.py | 2 +- machines/views.py | 5 ++--- templates/pagination.html | 17 +++++++++++++++++ users/templates/users/aff_users.html | 17 +++-------------- 8 files changed, 31 insertions(+), 48 deletions(-) create mode 100644 templates/pagination.html diff --git a/cotisations/templates/cotisations/aff_cotisations.html b/cotisations/templates/cotisations/aff_cotisations.html index dfee06e8..944c90fc 100644 --- a/cotisations/templates/cotisations/aff_cotisations.html +++ b/cotisations/templates/cotisations/aff_cotisations.html @@ -1,17 +1,6 @@ - {% if facture_list.paginator %} - - {% endif %} +{% if facture_list.paginator %} +{% include "pagination.html" with list=facture_list %} +{% endif %} diff --git a/machines/models.py b/machines/models.py index 509fb2cb..5fdc9758 100644 --- a/machines/models.py +++ b/machines/models.py @@ -66,4 +66,4 @@ def interface_post_save(sender, **kwargs): @receiver(post_delete, sender=Interface) def interface_post_delete(sender, **kwargs): user = kwargs['instance'].machine.user - user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) + #user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) diff --git a/machines/serializers.py b/machines/serializers.py index 375c4113..7b058d95 100644 --- a/machines/serializers.py +++ b/machines/serializers.py @@ -4,7 +4,7 @@ from machines.models import Interface class InterfaceSerializer( serializers.ModelSerializer): class Meta: model = Interface - fields = ('ipv4', 'mac_address', 'dns') + fields = ('ipv4', 'mac_address', 'dns', 'type') diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index 54be85e8..225c76ed 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -1,17 +1,6 @@ - {% if machines_list.paginator %} - - {% endif %} +{% if machines_list.paginator %} +{% include "pagination.html" with list=machines_list %} +{% endif %}
diff --git a/machines/urls.py b/machines/urls.py index 6327d2cc..5f1280f2 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -22,5 +22,5 @@ urlpatterns = [ url(r'^history/(?Pextension)/(?P[0-9]+)$', views.history, name='history'), url(r'^$', views.index, name='index'), url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'), - url(r'^rest/dns-ip/$', views.dns_ip, name='dns-ip'), + url(r'^rest/mac-ip-dns/$', views.mac_ip_dns, name='mac-ip-dns'), ] diff --git a/machines/views.py b/machines/views.py index 5843a88f..1eacebfe 100644 --- a/machines/views.py +++ b/machines/views.py @@ -415,8 +415,7 @@ def mac_ip(request): s.pop('dns') return JSONResponse(seria) -def dns_ip(request): +def mac_ip_dns(request): seria = interface_list(request) - for s in seria: - s.pop('mac_address') return JSONResponse(seria) + diff --git a/templates/pagination.html b/templates/pagination.html new file mode 100644 index 00000000..f69799a9 --- /dev/null +++ b/templates/pagination.html @@ -0,0 +1,17 @@ + + diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html index e113be6d..2830b1d1 100644 --- a/users/templates/users/aff_users.html +++ b/users/templates/users/aff_users.html @@ -1,17 +1,6 @@ - {% if users_list.paginator %} - - {% endif %} +{% if users_list.paginator %} +{% include "pagination.html" with list=users_list %} +{% endif %}
From 9525d500cc3469cb599fd5d4f2118993307f677d Mon Sep 17 00:00:00 2001 From: Dalahro Date: Sat, 8 Oct 2016 00:38:02 +0200 Subject: [PATCH 6/7] =?UTF-8?q?Seulement=2015=20r=C3=A9sultats=20affich?= =?UTF-8?q?=C3=A9s=20dans=20la=20recherche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/templates/search/index.html | 1 + search/views.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/search/templates/search/index.html b/search/templates/search/index.html index 9d60279d..0cdfe115 100644 --- a/search/templates/search/index.html +++ b/search/templates/search/index.html @@ -35,6 +35,7 @@ {% if not ban_list and not interfaces_list and not users_list and not facture_list and not white_list and not port_list and not switch_list%}

Aucun résultat

{% endif %} +
(Seulement les 15 premiers résultats sont affichés dans chaque catégorie)



diff --git a/search/views.py b/search/views.py index 22072e2e..4249f9b7 100644 --- a/search/views.py +++ b/search/views.py @@ -54,21 +54,21 @@ def search_result(search, type, request): for i in aff: if i == '0': - users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query) + users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query)[:15] query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search) if i == '1': - machines = Interface.objects.filter(machine=Machine.objects.filter(query)) | Interface.objects.filter(Q(dns__icontains = search)) + machines = Machine.objects.filter(query)[:15] if i == '2': - factures = Facture.objects.filter(query & date_query) + factures = Facture.objects.filter(query & date_query)[:15] if i == '3': - bans = Ban.objects.filter(query) + bans = Ban.objects.filter(query)[:15] if i == '4': - whitelists = Whitelist.objects.filter(query) + whitelists = Whitelist.objects.filter(query)[:15] if i == '5': - portlist = Port.objects.filter(details__icontains = search) + portlist = Port.objects.filter(details__icontains = search)[:15] if i == '6': - switchlist = Switch.objects.filter(details__icontains = search) - return {'users_list': users, 'interfaces_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist} + switchlist = Switch.objects.filter(details__icontains = search)[:15] + return {'users_list': users, 'machines_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist} @login_required def search(request): From 5612ae0cb642c35913ccb4473c04ce3e7e6353be Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 8 Oct 2016 10:46:55 +0200 Subject: [PATCH 7/7] =?UTF-8?q?Corrige=20un=20probl=C3=A8me=20de=20coh?= =?UTF-8?q?=C3=A9rence,=20le=20models=20ne=20peut=20contenir=20en=20argume?= =?UTF-8?q?nt=20une=20liste=20d'objet=20d'autres=20models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/models.py | 11 +++-------- re2o/settings.py | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/machines/models.py b/machines/models.py index 5fdc9758..a4c38aec 100644 --- a/machines/models.py +++ b/machines/models.py @@ -4,7 +4,7 @@ from django.dispatch import receiver from django.forms import ValidationError from macaddress.fields import MACAddressField - +from re2o.settings import MAIN_EXTENSION class Machine(models.Model): @@ -35,7 +35,7 @@ class Interface(models.Model): machine = models.ForeignKey('Machine', on_delete=models.CASCADE) type = models.ForeignKey('MachineType', on_delete=models.PROTECT) details = models.CharField(max_length=255, blank=True) - dns = models.CharField(help_text="Obligatoire et unique, doit se terminer en %s et ne pas comporter d'autres points" % ", ".join(Extension.objects.values_list('name', flat=True)), max_length=255, unique=True) + dns = models.CharField(help_text="Obligatoire et unique, doit se terminer par exemple en %s et ne pas comporter d'autres points" % MAIN_EXTENSION, max_length=255, unique=True) def is_active(self): """ Renvoie si une interface doit avoir accès ou non """ @@ -43,11 +43,6 @@ class Interface(models.Model): user = self.machine.user return machine.active and user.has_access() - #def save(self, *args, **kwargs): - # user = self.machine.user - # user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) - # super(Interface, self).save(*args, **kwargs) - def __str__(self): return self.dns @@ -66,4 +61,4 @@ def interface_post_save(sender, **kwargs): @receiver(post_delete, sender=Interface) def interface_post_delete(sender, **kwargs): user = kwargs['instance'].machine.user - #user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) + user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) diff --git a/re2o/settings.py b/re2o/settings.py index 58204747..cc8437bf 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, UID_RANGES +from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, MAIN_EXTENSION, UID_RANGES BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))