From 7be4f0044053a9713734ebc650c3d6fb3e6b4030 Mon Sep 17 00:00:00 2001 From: Skia Date: Sun, 11 Dec 2016 17:51:44 +0100 Subject: [PATCH] Fix is_in_group --- core/models.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/models.py b/core/models.py index a7db526c..b391cf24 100644 --- a/core/models.py +++ b/core/models.py @@ -202,13 +202,16 @@ class User(AbstractBaseUser): def is_in_group(self, group_name): """If the user is in the group passed in argument (as string or by id)""" group_id = 0 + g = None if isinstance(group_name, int): # Handle the case where group_name is an ID g = Group.objects.filter(id=group_name).first() - if g: - group_name = g.name - group_id = g.id - else: - return False + else: + g = Group.objects.filter(name=group_name).first() + if g: + group_name = g.name + group_id = g.id + else: + return False if group_id == settings.SITH_GROUP_PUBLIC_ID: return True if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked