From c5af76f9639b72235746fd654de9414c65d5c4de Mon Sep 17 00:00:00 2001 From: grisel-davy Date: Fri, 15 Jun 2018 11:00:12 +0200 Subject: [PATCH 1/7] Changement des couleurs et prise en ompte de l'activation du solde --- users/templates/users/profil.html | 97 ++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 13 deletions(-) diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 2442f167..2029a526 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -28,19 +28,90 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load logs_extra %} {% block title %}Profil{% endblock %} {% block content %} -

{{ users.surname }} {{users.name}}

-

Vous êtes {% if users.end_adhesion != None %} - un {{ users.class_name | lower}}{% else %} - non adhérent{% endif %} et votre connexion est {% if users.has_access %} -active{% else %}désactivée{% endif %}.

-{% if user_solde %} -

Votre solde est de {{ users.solde }}€. - - - Recharger - -

-{% endif %} + +
+

Bienvenue {{users.name}} {{ users.surname }}

+
+
+
+ {% if solde_activated %} +
+ {% else %} +
+ {% endif %} +
+ {% if users.is_adherent %} +
+
Connécté
+
Fin de connexion: {{user.end_adhesion|date:"d M Y"}}
+
+ {% else %} +
+
Non connécté
+ +
+ {% endif %} +
+
+ {% if solde_activated %} +
+
+
+
+
{{user.solde}}
+ +
+
+
+
+ {% endif %} + {% if solde_activated %} +
+ {% else %} +
+ {% endif %} +
+ {% if nb_machines %} +
+
+ {{nb_machines}} + Machines + +
+ +
+ {% else %} +
+
Aucune machine
+ +
+ {% endif %} +
+
+
+
+ +
From 6b9896143fb13b4fdfdae06c20f92fc9b374b60b Mon Sep 17 00:00:00 2001 From: grisel-davy Date: Sat, 16 Jun 2018 09:57:21 +0200 Subject: [PATCH 2/7] =?UTF-8?q?Prise=20en=20compte=20du=20bannissement=20e?= =?UTF-8?q?t=20d=C3=A9ployement=20des=20des=20infos=20si=20clique=20dans?= =?UTF-8?q?=20les=20titres?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/templates/users/profil.html | 37 ++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 2029a526..9628097a 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -40,20 +40,28 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endif %}
- {% if users.is_adherent %} -
-
Connécté
-
Fin de connexion: {{user.end_adhesion|date:"d M Y"}}
-
- {% else %} + {% if users.is_ban%}
-
Non connécté
+
Votre compte est banni
- - - Adhérer - + Fin du ban : {{user.end_ban|date:"d M Y"}} +
+
+ {% elif not users.is_adherent%} +
+
Non Connécté
+ + {% else %} +
+
Connécté
+
+ Fin de connexion: {{user.end_adhesion|date:"d M Y"}} +
{% endif %}
@@ -63,7 +71,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
-
{{user.solde}}
+
+ + {{user.solde}} +
@@ -83,7 +94,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if nb_machines %}
-
+
{{nb_machines}} Machines From 9321e6b5ed6d9680cc4ec0b50bb01d9817e7d46e Mon Sep 17 00:00:00 2001 From: grisel-davy Date: Fri, 15 Jun 2018 18:12:43 +0200 Subject: [PATCH 3/7] Envoi le la variable d'activation du solde --- users/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/users/views.py b/users/views.py index 0e37089d..d610f5a5 100644 --- a/users/views.py +++ b/users/views.py @@ -51,7 +51,7 @@ from reversion import revisions as reversion from cotisations.models import Facture, Paiement from machines.models import Machine -from preferences.models import GeneralOption +from preferences.models import GeneralOption, OptionalUser from re2o.views import form from re2o.utils import ( all_has_access, @@ -112,8 +112,7 @@ def new_user(request): GTU_sum_up = GeneralOption.get_cached_value('GTU_sum_up') GTU = GeneralOption.get_cached_value('GTU') if user.is_valid(): - user = user.save(commit=False) - user.save() + user = user.save() user.reset_passwd_mail(request) messages.success(request, "L'utilisateur %s a été crée, un mail\ pour l'initialisation du mot de passe a été envoyé" % user.pseudo) @@ -914,6 +913,8 @@ def profil(request, users, **_kwargs): 'ban_list': bans, 'white_list': whitelists, 'user_solde': user_solde, + 'allow_online_payment': allow_online_payment, + 'solde_activated': OptionalUser.objects.first().user_solde } ) From 7dcd32cb1e943a3ac3be47fb3f24592f69d60547 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Tue, 10 Jul 2018 23:36:01 +0200 Subject: [PATCH 4/7] Imports corrects --- users/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/users/views.py b/users/views.py index d610f5a5..a6444e33 100644 --- a/users/views.py +++ b/users/views.py @@ -51,7 +51,7 @@ from reversion import revisions as reversion from cotisations.models import Facture, Paiement from machines.models import Machine -from preferences.models import GeneralOption, OptionalUser +from preferences.models import OptionalUser, GeneralOption, AssoOption from re2o.views import form from re2o.utils import ( all_has_access, @@ -913,8 +913,8 @@ def profil(request, users, **_kwargs): 'ban_list': bans, 'white_list': whitelists, 'user_solde': user_solde, - 'allow_online_payment': allow_online_payment, - 'solde_activated': OptionalUser.objects.first().user_solde + 'solde_activated': Paiement.objects.filter(is_balance=True).exists(), + 'asso_name': AssoOption.objects.first().name } ) From a854174954493d3e25aa104ab1fc3b639227a73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Mon, 23 Jul 2018 21:41:30 +0000 Subject: [PATCH 5/7] Fix shit --- .../templates/cotisations/aff_article.html | 22 +++---------------- .../templates/cotisations/aff_paiement.html | 17 +------------- .../templates/machines/aff_extension.html | 1 - machines/templates/machines/aff_iptype.html | 1 - machines/templates/machines/aff_nas.html | 1 - machines/templates/machines/aff_service.html | 1 - 6 files changed, 4 insertions(+), 39 deletions(-) diff --git a/cotisations/templates/cotisations/aff_article.html b/cotisations/templates/cotisations/aff_article.html index bf2aa104..2afe726d 100644 --- a/cotisations/templates/cotisations/aff_article.html +++ b/cotisations/templates/cotisations/aff_article.html @@ -30,26 +30,12 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - - - - - - + @@ -60,16 +46,14 @@ with this program; if not, write to the Free Software Foundation, Inc., - + {% endfor %} diff --git a/cotisations/templates/cotisations/aff_paiement.html b/cotisations/templates/cotisations/aff_paiement.html index f85be9bb..46523928 100644 --- a/cotisations/templates/cotisations/aff_paiement.html +++ b/cotisations/templates/cotisations/aff_paiement.html @@ -30,19 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{{ article.name }}{{ article.prix }}{{ article.type_cotisation }}{{ article.duration }}{{ article.type_user }}{{ article.available_for_everyone }} - {% can_edit article %} - - - - {% acl_end %} - {% history_button article %} - {% trans "Article" %} {% trans "Price" %} {% trans "Cotisation type" %} {% trans "Duration (month)" %} {% trans "Concerned users" %}{% trans "Available for everyone" %}{% trans "Available for everyone" | tick %}
{{ article.type_cotisation }} {{ article.duration }} {{ article.type_user }}{{ article.available_for_everyone|tick }}{{ article.available_for_everyone }} {% can_edit article %} {% acl_end %} - - - + {% history_button article %}
- - - - @@ -62,9 +49,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %} - - - + {% history_button paiement %} {% endfor %} diff --git a/machines/templates/machines/aff_extension.html b/machines/templates/machines/aff_extension.html index 94550604..ba444eca 100644 --- a/machines/templates/machines/aff_extension.html +++ b/machines/templates/machines/aff_extension.html @@ -54,7 +54,6 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %} {% acl_end %} {% history_button extension %} - {% include 'buttons/history.html' with href='machines:history' name='extension' id=extension.id %} {% endfor %} diff --git a/machines/templates/machines/aff_iptype.html b/machines/templates/machines/aff_iptype.html index d0bff234..fa2a2767 100644 --- a/machines/templates/machines/aff_iptype.html +++ b/machines/templates/machines/aff_iptype.html @@ -55,7 +55,6 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include 'buttons/edit.html' with href='machines:edit-iptype' id=type.id %} {% acl_end %} {% history_button type %} - {% include 'buttons/history.html' with href='machines:history' name='iptype' id=type.id %} {% endfor %} diff --git a/machines/templates/machines/aff_nas.html b/machines/templates/machines/aff_nas.html index 86e75c7d..78dc2d97 100644 --- a/machines/templates/machines/aff_nas.html +++ b/machines/templates/machines/aff_nas.html @@ -49,7 +49,6 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include 'buttons/edit.html' with href='machines:edit-nas' id=nas.id %} {% acl_end %} {% history_button nas %} - {% include 'buttons/history.html' with href='machines:history' name='nas' id=nas.id %} {% endfor %} diff --git a/machines/templates/machines/aff_service.html b/machines/templates/machines/aff_service.html index 95705858..6ca6278b 100644 --- a/machines/templates/machines/aff_service.html +++ b/machines/templates/machines/aff_service.html @@ -47,7 +47,6 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include 'buttons/edit.html' with href='machines:edit-service' id=service.id %} {% acl_end %} {% history_button service %} - {% include 'buttons/history.html' with href='machines:history' name='service' id=service.id %} {% endfor %} From b5513db8ae3afd972aae4bf32004e0bb7c822518 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 26 Jul 2018 20:11:13 +0200 Subject: [PATCH 6/7] Suppression du dictionnaire de mort dans re2o/templatetags/acl.py --- re2o/templatetags/acl.py | 90 +++++++++++----------------------------- 1 file changed, 25 insertions(+), 65 deletions(-) diff --git a/re2o/templatetags/acl.py b/re2o/templatetags/acl.py index fccbea1d..269ea051 100644 --- a/re2o/templatetags/acl.py +++ b/re2o/templatetags/acl.py @@ -74,82 +74,42 @@ import sys from django import template from django.template.base import Node, NodeList +from django.contrib.contenttypes.models import ContentType -import cotisations -import machines -import preferences -import topologie -import users register = template.Library() -MODEL_NAME = { - # cotisations - 'Facture': cotisations.models.Facture, - 'Vente': cotisations.models.Vente, - 'Article': cotisations.models.Article, - 'Banque': cotisations.models.Banque, - 'Paiement': cotisations.models.Paiement, - 'Cotisation': cotisations.models.Cotisation, - # machines - 'Machine': machines.models.Machine, - 'MachineType': machines.models.MachineType, - 'IpType': machines.models.IpType, - 'Vlan': machines.models.Vlan, - 'Nas': machines.models.Nas, - 'SOA': machines.models.SOA, - 'Extension': machines.models.Extension, - 'Mx': machines.models.Mx, - 'Ns': machines.models.Ns, - 'Txt': machines.models.Txt, - 'Srv': machines.models.Srv, - 'Interface': machines.models.Interface, - 'Domain': machines.models.Domain, - 'IpList': machines.models.IpList, - 'Ipv6List': machines.models.Ipv6List, - 'machines.Service': machines.models.Service, - 'Service_link': machines.models.Service_link, - 'OuverturePortList': machines.models.OuverturePortList, - 'OuverturePort': machines.models.OuverturePort, - # preferences - 'OptionalUser': preferences.models.OptionalUser, - 'OptionalMachine': preferences.models.OptionalMachine, - 'OptionalTopologie': preferences.models.OptionalTopologie, - 'GeneralOption': preferences.models.GeneralOption, - 'preferences.Service': preferences.models.Service, - 'AssoOption': preferences.models.AssoOption, - 'MailMessageOption': preferences.models.MailMessageOption, - # topologie - 'Stack': topologie.models.Stack, - 'Switch': topologie.models.Switch, - 'AccessPoint': topologie.models.AccessPoint, - 'ModelSwitch': topologie.models.ModelSwitch, - 'ConstructorSwitch': topologie.models.ConstructorSwitch, - 'Port': topologie.models.Port, - 'Room': topologie.models.Room, - 'Building': topologie.models.Building, - 'SwitchBay': topologie.models.SwitchBay, - # users - 'User': users.models.User, - 'Adherent': users.models.Adherent, - 'Club': users.models.Club, - 'ServiceUser': users.models.ServiceUser, - 'School': users.models.School, - 'ListRight': users.models.ListRight, - 'ListShell': users.models.ListShell, - 'Ban': users.models.Ban, - 'Whitelist': users.models.Whitelist, -} - def get_model(model_name): """Retrieve the model object from its name""" + splitted = model_name.split('.') + if len(splitted) > 1: + try: + app_label, name = splitted + except ValueError: + raise template.TemplateSyntaxError( + "%r is an inconsistent model name" % model_name + ) + else: + app_label, name = None, splitted[0] try: - return MODEL_NAME[model_name] - except KeyError: + if app_label is not None: + content_type = ContentType.objects.get( + model=name, + app_label=app_label + ) + else: + content_type = ContentType.objects.get(model=name) + except ContentType.DoesNotExist: raise template.TemplateSyntaxError( "%r is not a valid model for an acl tag" % model_name ) + except ContentType.MultipleObjectsReturned: + raise template.TemplateSyntaxError( + "More than one model found for %r. Try with `app.model`." + % model_name + ) + return content_type.model_class() def get_callback(tag_name, obj=None): From 53079c0a9e33399faeb091a6a93a547eb53176ff Mon Sep 17 00:00:00 2001 From: chirac Date: Sat, 28 Jul 2018 23:13:51 +0200 Subject: [PATCH 7/7] Fix acl.py lower --- re2o/templatetags/acl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/re2o/templatetags/acl.py b/re2o/templatetags/acl.py index 269ea051..fe13c5ac 100644 --- a/re2o/templatetags/acl.py +++ b/re2o/templatetags/acl.py @@ -95,11 +95,11 @@ def get_model(model_name): try: if app_label is not None: content_type = ContentType.objects.get( - model=name, + model=name.lower(), app_label=app_label ) else: - content_type = ContentType.objects.get(model=name) + content_type = ContentType.objects.get(model=name.lower()) except ContentType.DoesNotExist: raise template.TemplateSyntaxError( "%r is not a valid model for an acl tag" % model_name
{{ paiement.moyen }}{{ paiement.available_for_everyone }} - {{paiement.get_payment_method_name}} - - {% can_edit paiement %} - - - - {% acl_end %} - {% history_button paiement %} - {% trans "Payment type" %} {% trans "Is available for everyone" %} {% trans "Custom payment method" %}