diff --git a/cotisations/models.py b/cotisations/models.py index 4e83b075..0e5b49ef 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -149,11 +149,13 @@ class Facture(FieldPermissionModelMixin, models.Model): else: return True, None - def can_change_control(user, *args, **kwargs): - return user.has_perms(('tresorier',)), "Vous ne pouvez pas éditer le controle sans droit trésorier" + @classmethod + def can_change_control(cls, user_request, *args, **kwargs): + return user_request.has_perms(('tresorier',)), "Vous ne pouvez pas éditer le controle sans droit trésorier" - def can_change_pdf(user, *args, **kwargs): - return user.has_perms(('tresorier',)), "Vous ne pouvez pas éditer une facture sans droit trésorier" + @classmethod + def can_change_pdf(cls, user_request, *args, **kwargs): + return user_request.has_perms(('tresorier',)), "Vous ne pouvez pas éditer une facture sans droit trésorier" field_permissions = { 'control': can_change_control, diff --git a/re2o/field_permissions.py b/re2o/field_permissions.py index 184778af..4a229c9c 100644 --- a/re2o/field_permissions.py +++ b/re2o/field_permissions.py @@ -42,7 +42,7 @@ class FieldPermissionModelMixin: # Try to find a user setting that qualifies them for permission. for perm in checks: if callable(perm): - result, reason = perm(user=user) + result, reason = perm(user_request=user) if result is not None: return result else: diff --git a/users/models.py b/users/models.py index 6bdca96c..3233ae86 100644 --- a/users/models.py +++ b/users/models.py @@ -820,13 +820,16 @@ class User(FieldPermissionModelMixin, AbstractBaseUser): else: return False, u"Vous ne pouvez éditer un autre utilisateur que vous même" - def can_change_state(user_request, *args, **kwargs): + @classmethod + def can_change_state(cls, user_request, *args, **kwargs): return user_request.has_perms(('bureau',)), "Droit bureau requis pour changer l'état" - def can_change_shell(user_request, *args, **kwargs): + @classmethod + def can_change_shell(cls, user_request, *args, **kwargs): return user_request.has_perms(('cableur',)), "Droit requis pour changer le shell" - def can_change_force(user_request, *args, **kwargs): + @classmethod + def can_change_force(cls, user_request, *args, **kwargs): return user_request.has_perms(('cableur',)), "Droit requis pour forcer le déménagement" def can_delete(self, user_request, *args, **kwargs): diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index f17bf809..8cb52d8b 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -28,25 +28,25 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Profil{% endblock %} {% block content %} -
Prénom | -{{ user.name }} | +{{ users.name }} | Nom | -{{ user.surname }} | +{{ users.surname }} | ||
---|---|---|---|---|---|---|---|
Pseudo | -{{ user.pseudo }} | +{{ users.pseudo }} | {{ user.email }} | +{{ users.email }} | |||
Chambre | -{{ user.room }} | +{{ users.room }} | Téléphone | -{{ user.telephone }} | +{{ users.telephone }} | ||
École | -{{ user.school }} | +{{ users.school }} | Commentaire | -{{ user.comment }} | +{{ users.comment }} | ||
Date d'inscription | -{{ user.registered }} | +{{ users.registered }} | Dernière connexion | -{{ user.last_login }} | +{{ users.last_login }} | ||
Fin d'adhésion | - {% if user.end_adhesion != None %} -{{ user.end_adhesion }} | + {% if users.end_adhesion != None %} +{{ users.end_adhesion }} | {% else %}Non adhérent | {% endif %}Accès gracieux | - {% if user.end_whitelist != None %} -{{ user.end_whitelist }} | + {% if users.end_whitelist != None %} +{{ users.end_whitelist }} | {% else %}Aucun | {% endif %}
Bannissement | - {% if user.end_ban != None %} -{{ user.end_ban }} | + {% if users.end_ban != None %} +{{ users.end_ban }} | {% else %}Non banni | {% endif %}Statut | - {% if user.state == 0 %} + {% if users.state == 0 %}Actif | - {% elif user.state == 1 %} + {% elif users.state == 1 %}Désactivé | {% else %}Archivé | @@ -116,8 +116,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Accès internet | - {% if user.has_access == True %} -Actif (jusqu'au {{ user.end_access }}) | + {% if users.has_access == True %} +Actif (jusqu'au {{ users.end_access }}) | {% else %}Désactivé | {% endif %} @@ -131,16 +131,16 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if user_solde %}||||
Solde | -{{ user.solde }} € | +{{ users.solde }} € | Shell | -{{ user.shell }} | - {% endif %} + {% endif %} + {% if users.shell %} +Shell | +{{ users.shell }} | + {% endif %}
Aucune machine
{% endif %}Aucune facture
{% endif %}Aucun bannissement
{% endif %}