From c40171fe86e5c3bcc23db3bb71a3d087bdd539a9 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 18 Oct 2016 23:02:53 +0200 Subject: [PATCH] Clean permission check for alcohol and counter ban --- core/models.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/models.py b/core/models.py index 7638ae14..5101980d 100644 --- a/core/models.py +++ b/core/models.py @@ -243,11 +243,11 @@ class User(AbstractBaseUser): @property 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 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): create = False @@ -439,6 +439,14 @@ class AnonymousUser(AuthAnonymousUser): def is_launderette_manager(self): 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): """ The anonymous user is only the public group