mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-27 01:13:46 +00:00
Crée les droits si ils n'existent pas
This commit is contained in:
parent
32ce5dcf53
commit
3d78e09bb9
1 changed files with 10 additions and 5 deletions
|
@ -221,15 +221,20 @@ class User(AbstractBaseUser):
|
||||||
|
|
||||||
|
|
||||||
def has_right(self, right):
|
def has_right(self, right):
|
||||||
return Right.objects.filter(user=self).filter(right=ListRight.objects.get(listright=right)).exists()
|
try:
|
||||||
|
list_right = ListRight.objects.get(listright=right)
|
||||||
|
except:
|
||||||
|
list_right = ListRight(listright=right, gid=get_fresh_gid())
|
||||||
|
list_right.save()
|
||||||
|
return Right.objects.filter(user=self).filter(right=list_right).exists()
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_bureau(self):
|
def is_bureau(self):
|
||||||
return Right.objects.filter(user=self).filter(right=ListRight.objects.get(listright='bureau')).exists()
|
return self.has_right('bureau')
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_bofh(self):
|
def is_bofh(self):
|
||||||
return Right.objects.filter(user=self).filter(right=ListRight.objects.get(listright='bofh')).exists()
|
return self.has_right('bofh')
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_cableur(self):
|
def is_cableur(self):
|
||||||
|
@ -237,11 +242,11 @@ class User(AbstractBaseUser):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_trez(self):
|
def is_trez(self):
|
||||||
return Right.objects.filter(user=self).filter(right=ListRight.objects.get(listright='trésorier')).exists()
|
return self.has_right('trésorier')
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_infra(self):
|
def is_infra(self):
|
||||||
return Right.objects.filter(user=self).filter(right=ListRight.objects.get(listright='infra')).exists()
|
return self.has_right('infra')
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def end_adhesion(self):
|
def end_adhesion(self):
|
||||||
|
|
Loading…
Reference in a new issue