mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
Fix is_in_group
This commit is contained in:
parent
7ee4d36c3d
commit
7be4f00440
@ -202,8 +202,11 @@ 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()
|
||||||
|
else:
|
||||||
|
g = Group.objects.filter(name=group_name).first()
|
||||||
if g:
|
if g:
|
||||||
group_name = g.name
|
group_name = g.name
|
||||||
group_id = g.id
|
group_id = g.id
|
||||||
|
Loading…
Reference in New Issue
Block a user