Clean permission check for alcohol and counter ban

This commit is contained in:
Antoine Bartuccio 2016-10-18 23:02:53 +02:00
parent 2daaf992f2
commit c40171fe86

View File

@ -243,11 +243,11 @@ class User(AbstractBaseUser):
@property @property
def is_banned_alcohol(self): def is_banned_alcohol(self):
return self.groups.filter(name=settings.SITH_GROUPS['banned-alcohol']['name']).exists() return self.is_in_group(settings.SITH_GROUPS['banned-alcohol']['name'])
@property @property
def is_banned_counter(self): def is_banned_counter(self):
return self.groups.filter(name=settings.SITH_GROUPS['banned-from-counters']['name']).exists() return self.is_in_group(settings.SITH_GROUPS['banned-from-counters']['name'])
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
create = False create = False
@ -439,6 +439,14 @@ class AnonymousUser(AuthAnonymousUser):
def is_launderette_manager(self): def is_launderette_manager(self):
return False return False
@property
def is_banned_alcohol(self):
return False
@property
def is_banned_conuter(self):
return False
def is_in_group(self, group_name): def is_in_group(self, group_name):
""" """
The anonymous user is only the public group The anonymous user is only the public group