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 %} diff --git a/re2o/templatetags/acl.py b/re2o/templatetags/acl.py index d36bdfa7..fe13c5ac 100644 --- a/re2o/templatetags/acl.py +++ b/re2o/templatetags/acl.py @@ -74,83 +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, - 'DName': machines.models.DName, - '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.lower(), + app_label=app_label + ) + else: + 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 ) + 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): diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 2442f167..9628097a 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -28,19 +28,101 @@ 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_ban%} +
+
Votre compte est banni
+
+ 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 %} +
+
+ {% if solde_activated %} +
+
+
+
+
+ + {{user.solde}} +
+ +
+
+
+
+ {% endif %} + {% if solde_activated %} +
+ {% else %} +
+ {% endif %} +
+ {% if nb_machines %} +
+
+ {{nb_machines}} + Machines + +
+ +
+ {% else %} +
+
Aucune machine
+ +
+ {% endif %} +
+
+
+
+ +
diff --git a/users/views.py b/users/views.py index 0e37089d..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 +from preferences.models import OptionalUser, GeneralOption, AssoOption 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, + 'solde_activated': Paiement.objects.filter(is_balance=True).exists(), + 'asso_name': AssoOption.objects.first().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" %}