Merge branch 'Aufinal/bds_perms' into 'master'
Le groupe BDS a des permissions normales Closes #263 See merge request klub-dev-ens/gestioCOF!444
This commit is contained in:
commit
0011cfe8f7
4 changed files with 27 additions and 14 deletions
|
@ -27,6 +27,7 @@ adhérents ni des cotisations.
|
||||||
|
|
||||||
- Ajout d'un bouton pour supprimer un compte
|
- Ajout d'un bouton pour supprimer un compte
|
||||||
- Le nombre d'adhérent⋅es est affiché sur la page d'accueil
|
- Le nombre d'adhérent⋅es est affiché sur la page d'accueil
|
||||||
|
- le groupe BDS a les bonnes permissions
|
||||||
|
|
||||||
### Site du COF
|
### Site du COF
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
default_app_config = "bds.apps.BdsConfig"
|
24
bds/apps.py
24
bds/apps.py
|
@ -1,5 +1,29 @@
|
||||||
|
from django import apps as global_apps
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
from django.db.models import Q
|
||||||
|
from django.db.models.signals import post_migrate
|
||||||
|
|
||||||
|
|
||||||
|
def bds_group_perms(app_config, apps=global_apps, **kwargs):
|
||||||
|
try:
|
||||||
|
Permission = apps.get_model("auth", "Permission")
|
||||||
|
Group = apps.get_model("auth", "Group")
|
||||||
|
|
||||||
|
group = Group.objects.get(name="Burô du BDS")
|
||||||
|
perms = Permission.objects.filter(
|
||||||
|
Q(content_type__app_label="bds")
|
||||||
|
| Q(content_type__app_label="auth") & Q(content_type__model="user")
|
||||||
|
)
|
||||||
|
group.permissions.set(perms)
|
||||||
|
group.save()
|
||||||
|
|
||||||
|
except (LookupError, Group.DoesNotExist):
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class BdsConfig(AppConfig):
|
class BdsConfig(AppConfig):
|
||||||
name = "bds"
|
name = "bds"
|
||||||
|
verbose_name = "Gestion des adhérent·e·s du BDS"
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
post_migrate.connect(bds_group_perms, sender=self)
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
# Generated by Django 2.2 on 2019-07-17 14:56
|
# Generated by Django 2.2 on 2019-07-17 14:56
|
||||||
|
|
||||||
from django.contrib.auth.management import create_permissions
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
|
|
||||||
def create_bds_buro_group(apps, schema_editor):
|
def create_bds_buro_group(apps, schema_editor):
|
||||||
for app_config in apps.get_app_configs():
|
|
||||||
create_permissions(app_config, apps=apps, verbosity=0)
|
|
||||||
|
|
||||||
Group = apps.get_model("auth", "Group")
|
Group = apps.get_model("auth", "Group")
|
||||||
Permission = apps.get_model("auth", "Permission")
|
Group.objects.get_or_create(name="Burô du BDS")
|
||||||
group, created = Group.objects.get_or_create(name="Burô du BDS")
|
|
||||||
if created:
|
|
||||||
perms = Permission.objects.filter(
|
|
||||||
Q(content_type__app_label="bds")
|
|
||||||
| Q(content_type__app_label="auth") & Q(content_type__model="user")
|
|
||||||
)
|
|
||||||
group.permissions.set(perms)
|
|
||||||
group.save()
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
Loading…
Reference in a new issue