Merge branch 'Kerl/bds_groups' into 'supportBDS'

BDS groups and permissions

Creates groups and permissions for the BDS members and staff.

Fixes #136 

See merge request !176
This commit is contained in:
Martin Pepin 2017-02-23 12:58:44 +01:00
commit cc25685aa3
3 changed files with 61 additions and 1 deletions

View file

@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.auth.models import Group, Permission
from django.db import migrations
def create_groups(apps, schema_editor):
from django.contrib.auth.management import create_permissions
apps.models_module = True
create_permissions(apps, verbosity=0)
apps.models_module = None
memberp = Permission.objects.get(
codename="member",
content_type__app_label="bds"
)
burop = Permission.objects.get(
codename="buro",
content_type__app_label="bds"
)
# Creates the groups for BDS members and staff
member = Group.objects.create(name="bds_members")
buro = Group.objects.create(name="bds_buro")
# Associates the permissions to the respective groups
member.permissions = [memberp]
buro.permissions = [memberp, burop]
class Migration(migrations.Migration):
dependencies = [
('bds', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='bdsprofile',
options={
'permissions': [
('member', 'Is a BDS member'),
('buro', 'Is part of the BDS staff')
],
'verbose_name': 'Profil BDS',
'verbose_name_plural': 'Profils BDS'
},
),
migrations.RunPython(create_groups, migrations.RunPython.noop),
]

View file

@ -55,3 +55,11 @@ class BdsProfile(models.Model):
default='CASH',
choices=PAYMENT_METHOD_CHOICES,
max_length=6)
class Meta:
verbose_name = "Profil BDS"
verbose_name_plural = "Profils BDS"
permissions = [
("member", "Is a BDS member"),
("buro", "Is part of the BDS staff")
]

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.auth.models import Group, Permission
from django.contrib.auth.models import Group
from django.db import migrations, models