forked from DGNum/gestioCOF
Move permission handling to loadkfetdevdata
This commit is contained in:
parent
d3185f25c3
commit
c5d7eb9d30
2 changed files with 10 additions and 14 deletions
|
@ -37,19 +37,9 @@ class KFetPermission(Permission):
|
|||
|
||||
|
||||
class KFetGroup(Group):
|
||||
# Même si on n'ajoute que des méthodes, on fait un héritage complet pour
|
||||
# On fait un héritage complet pour
|
||||
# mieux distinguer les groupes K-Fêt via l'ORM (i.e. faire `KFetGroup.objects.all`)
|
||||
|
||||
def give_admin_access(self):
|
||||
perms = KFetPermission.objects.all()
|
||||
self.permissions.add(*perms)
|
||||
|
||||
def give_staff_access(self):
|
||||
perms = KFetPermission.objects.filter(
|
||||
codename__in=["is_team", "perform_deposit", "add_account", "add_transfer"]
|
||||
)
|
||||
self.permissions.add(*perms)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Groupe K-Fêt")
|
||||
verbose_name_plural = _("Groupes K-Fêt")
|
||||
|
|
|
@ -12,7 +12,7 @@ from django.utils import timezone
|
|||
|
||||
from gestioncof.management.base import MyBaseCommand
|
||||
from gestioncof.models import CofProfile
|
||||
from kfet.auth.models import KFetGroup
|
||||
from kfet.auth.models import KFetGroup, KFetPermission
|
||||
from kfet.models import (
|
||||
Account,
|
||||
Article,
|
||||
|
@ -37,8 +37,14 @@ class Command(MyBaseCommand):
|
|||
group_chef, _ = KFetGroup.objects.get_or_create(name="K-Fêt César")
|
||||
group_boy, _ = KFetGroup.objects.get_or_create(name="K-Fêt Légionnaire")
|
||||
|
||||
group_chef.give_admin_access()
|
||||
group_chef.give_staff_access()
|
||||
# Give relevant permissions to both groups
|
||||
chef_perms = KFetPermission.objects.all()
|
||||
group_chef.permissions.add(*chef_perms)
|
||||
|
||||
boy_perms = KFetPermission.objects.filter(
|
||||
codename__in=["is_team", "perform_deposit", "add_account", "add_transfer"]
|
||||
)
|
||||
group_boy.permissions.add(*boy_perms)
|
||||
|
||||
# ---
|
||||
# Comptes
|
||||
|
|
Loading…
Reference in a new issue