Commit 7be4f004 authored by Skia's avatar Skia
Browse files

Fix is_in_group

parent 7ee4d36c
Pipeline #494 passed with stage
in 2 minutes and 28 seconds
...@@ -202,13 +202,16 @@ class User(AbstractBaseUser): ...@@ -202,13 +202,16 @@ class User(AbstractBaseUser):
def is_in_group(self, group_name): def is_in_group(self, group_name):
"""If the user is in the group passed in argument (as string or by id)""" """If the user is in the group passed in argument (as string or by id)"""
group_id = 0 group_id = 0
g = None
if isinstance(group_name, int): # Handle the case where group_name is an ID if isinstance(group_name, int): # Handle the case where group_name is an ID
g = Group.objects.filter(id=group_name).first() g = Group.objects.filter(id=group_name).first()
if g: else:
group_name = g.name g = Group.objects.filter(name=group_name).first()
group_id = g.id if g:
else: group_name = g.name
return False group_id = g.id
else:
return False
if group_id == settings.SITH_GROUP_PUBLIC_ID: if group_id == settings.SITH_GROUP_PUBLIC_ID:
return True return True
if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment