8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 15:12:25 +00:00

Cosmétique pour 5-1

This commit is contained in:
Gabriel Detraz 2018-01-07 02:14:41 +01:00 committed by root
parent f262421ea0
commit 0c0df90d75
2 changed files with 21 additions and 19 deletions

View file

@ -705,8 +705,9 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
user_request has the 'cableur' right. user_request has the 'cableur' right.
""" """
if self.is_class_club and user_request.is_class_adherent: if self.is_class_club and user_request.is_class_adherent:
if self == user_request or user_request.has_perm('users.change_user') or\ if self == user_request or \
user_request.adherent in self.club.administrators.all(): user_request.has_perm('users.change_user') or \
user_request.adherent in self.club.administrators.all():
return True, None return True, None
else: else:
return False, u"Vous n'avez pas le droit d'éditer ce club" return False, u"Vous n'avez pas le droit d'éditer ce club"
@ -718,14 +719,16 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
def can_change_password(self, user_request, *args, **kwargs): def can_change_password(self, user_request, *args, **kwargs):
if self.is_class_club and user_request.is_class_adherent: if self.is_class_club and user_request.is_class_adherent:
if self == user_request or user_request.has_perm('users.change_user_password') or\ if self == user_request or \
user_request.adherent in self.club.administrators.all(): user_request.has_perm('users.change_user_password') or \
user_request.adherent in self.club.administrators.all():
return True, None return True, None
else: else:
return False, u"Vous n'avez pas le droit d'éditer ce club" return False, u"Vous n'avez pas le droit d'éditer ce club"
else: else:
if self == user_request or user_request.has_perm('users.change_user_groups'): if self == user_request or \
# Peut éditer les groupes d'un user, c'est un privilège élevé, True user_request.has_perm('users.change_user_groups'):
# Peut éditer les groupes d'un user, c'est un privilège élevé, True
return True, None return True, None
elif user_request.has_perm('users.change_user') and not self.groups.all(): elif user_request.has_perm('users.change_user') and not self.groups.all():
return True, None return True, None
@ -780,9 +783,10 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
text text
""" """
if self.is_class_club and user_request.is_class_adherent: if self.is_class_club and user_request.is_class_adherent:
if self == user_request or user_request.has_perm('users.view_user') or\ if self == user_request or \
user_request.adherent in self.club.administrators.all() or\ user_request.has_perm('users.view_user') or \
user_request.adherent in self.club.members.all(): user_request.adherent in self.club.administrators.all() or \
user_request.adherent in self.club.members.all():
return True, None return True, None
else: else:
return False, u"Vous n'avez pas le droit de voir ce club" return False, u"Vous n'avez pas le droit de voir ce club"
@ -961,12 +965,9 @@ class ServiceUser(AbstractBaseUser):
:return: a message and a boolean which is True if the user can create :return: a message and a boolean which is True if the user can create
or if the `options.all_can_create` is set. or if the `options.all_can_create` is set.
""" """
options, _created = OptionalUser.objects.get_or_create() return user_request.has_perm('users.add_serviceuser'), (
if options.all_can_create: u"Vous n'avez pas le droit de créer un service user"
return True, None )
else:
return user_request.has_perm('users.add_serviceuser'), u"Vous n'avez pas le droit de\
créer un service user"
def can_edit(self, user_request, *args, **kwargs): def can_edit(self, user_request, *args, **kwargs):
"""Check if an user can edit a ServiceUser object. """Check if an user can edit a ServiceUser object.
@ -975,8 +976,9 @@ class ServiceUser(AbstractBaseUser):
:param user_request: The user who requests to edit self. :param user_request: The user who requests to edit self.
:return: a message and a boolean which is True if edition is granted. :return: a message and a boolean which is True if edition is granted.
""" """
return user_request.has_perm('users.change_serviceuser'), u"Vous n'avez pas le droit d'éditer\ return user_request.has_perm('users.change_serviceuser'), (
les services users" u"Vous n'avez pas le droit d'éditer les services users"
)
def can_delete(self, user_request, *args, **kwargs): def can_delete(self, user_request, *args, **kwargs):
"""Check if an user can delete a ServiceUser object. """Check if an user can delete a ServiceUser object.
@ -1027,7 +1029,7 @@ def service_user_post_delete(sender, **kwargs):
class School(models.Model): class School(models.Model):
""" Etablissement d'enseignement""" """ Etablissement d'enseignement"""
PRETTY_NAME = "Etablissements enregistrés" PRETTY_NAME = "Établissements enregistrés"
name = models.CharField(max_length=255) name = models.CharField(max_length=255)

View file

@ -132,7 +132,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>Aucun</td> <td>Aucun</td>
{% endif %} {% endif %}
</tr> </tr>
{% if user_solde %} {% if user_solde %}
<tr> <tr>
<th>Solde</th> <th>Solde</th>
<td>{{ users.solde }} €</td> <td>{{ users.solde }} €</td>