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 %} -

{{ user.class_name }}

+

{{ users.class_name }}

- + Editer - + Changer le mot de passe - + Changer le statut - + Ajouter un droit - + Historique @@ -57,58 +57,58 @@ with this program; if not, write to the Free Software Foundation, Inc., - + - + - + - + - + - + - + - + - + - + - {% if user.end_adhesion != None %} - + {% if users.end_adhesion != None %} + {% else %} {% endif %} - {% if user.end_whitelist != None %} - + {% if users.end_whitelist != None %} + {% else %} {% endif %} - {% if user.end_ban != None %} - + {% if users.end_ban != None %} + {% else %} {% endif %} - {% if user.state == 0 %} + {% if users.state == 0 %} - {% elif user.state == 1 %} + {% elif users.state == 1 %} {% else %} @@ -116,8 +116,8 @@ with this program; if not, write to the Free Software Foundation, Inc., - {% if user.has_access == True %} - + {% if users.has_access == True %} + {% else %} {% endif %} @@ -131,16 +131,16 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if user_solde %} - + - {% endif %} - {% if user.shell %} - - - {% endif %} + {% endif %} + {% if users.shell %} + + + {% endif %}
Prénom{{ user.name }}{{ users.name }} Nom{{ user.surname }}{{ users.surname }}
Pseudo{{ user.pseudo }}{{ users.pseudo }} E-mail{{ 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{{ user.end_adhesion }}{{ users.end_adhesion }}Non adhérentAccès gracieux{{ user.end_whitelist }}{{ users.end_whitelist }}Aucun
Bannissement{{ user.end_ban }}{{ users.end_ban }}Non banniStatutActifDésactivéArchivé
Accès internetActif (jusqu'au {{ user.end_access }})Actif (jusqu'au {{ users.end_access }})Désactivé
Solde{{ user.solde }} €{{ users.solde }} €
Shell{{ user.shell }}Shell{{ users.shell }}
- {% if user.is_class_club %} - + {% if users.is_class_club %} + Gérer admin et membres @@ -153,7 +153,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Pseudo - {% for admin in user.club.administrators.all %} + {% for admin in users.club.administrators.all %} {{ admin.surname }} {{ admin.name }} @@ -170,7 +170,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Pseudo - {% for admin in user.club.members.all %} + {% for admin in users.club.members.all %} {{ admin.surname }} {{ admin.name }} @@ -180,28 +180,28 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endif %}

Machines

-

Ajouter une machine

+

Ajouter une machine

{% if machines_list %} {% include "machines/aff_machines.html" with machines_list=machines_list %} {% else %}

Aucune machine

{% endif %}

Cotisations

-

{% can_create Facture %} Ajouter une cotisation{% acl_end %} {% if user_solde %} Modifier le solde{% endif%}

+

{% can_create Facture %} Ajouter une cotisation{% acl_end %} {% if user_solde %} Modifier le solde{% endif%}

{% if facture_list %} {% include "cotisations/aff_cotisations.html" with facture_list=facture_list %} {% else %}

Aucune facture

{% endif %}

Bannissements

- {% can_create Ban %}

Ajouter un bannissement

{% acl_end %} + {% can_create Ban %}

Ajouter un bannissement

{% acl_end %} {% if ban_list %} {% include "users/aff_bans.html" with ban_list=ban_list %} {% else %}

Aucun bannissement

{% endif %}

Accès à titre gracieux :

- {% can_create Whitelist %}

Accorder un accès à titre gracieux

{% acl_end %} + {% can_create Whitelist %}

Accorder un accès à titre gracieux

{% acl_end %} {% if white_list %} {% include "users/aff_whitelists.html" with white_list=white_list %} {% else %} diff --git a/users/views.py b/users/views.py index e52ba095..c430bd1b 100644 --- a/users/views.py +++ b/users/views.py @@ -124,7 +124,7 @@ def password_change_action(u_form, user, request, req=False): def new_user(request): """ Vue de création d'un nouvel utilisateur, envoie un mail pour le mot de passe""" - user = AdherentForm(request.POST or None) + user = AdherentForm(request.POST or None, user=request.user) if user.is_valid(): user = user.save(commit=False) with transaction.atomic(), reversion.create_revision(): @@ -146,7 +146,7 @@ def new_user(request): def new_club(request): """ Vue de création d'un nouveau club, envoie un mail pour le mot de passe""" - club = ClubForm(request.POST or None) + club = ClubForm(request.POST or None, user=request.user) if club.is_valid(): club = club.save(commit=False) with transaction.atomic(), reversion.create_revision(): @@ -803,7 +803,7 @@ def profil(request, users, userid): request, 'users/profil.html', { - 'user': users, + 'users': users, 'machines_list': machines, 'facture_list': factures, 'ban_list': bans,