2017-04-10 19:38:49 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Generated by Django 1.10.5 on 2017-04-10 18:53
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
|
2018-02-11 10:56:44 +01:00
|
|
|
|
2017-04-10 19:38:49 +02:00
|
|
|
def create_default_groups_permissions(apps, schema_editor):
|
|
|
|
# We can't import the Person model directly as it may be a newer
|
|
|
|
# version than this migration expects. We use the historical version.
|
|
|
|
Permission = apps.get_model("auth", "Permission")
|
|
|
|
Group = apps.get_model("auth", "Group")
|
|
|
|
lg = Group(name='Location')
|
|
|
|
lg.save()
|
|
|
|
lg.permissions.add(Permission.objects.get(codename="add_locationdata"))
|
|
|
|
ag = Group(name='Accounting')
|
|
|
|
ag.save()
|
|
|
|
ag.permissions.add(Permission.objects.get(codename="change_accounting"))
|
|
|
|
|
2018-02-11 10:56:44 +01:00
|
|
|
|
2017-04-10 19:38:49 +02:00
|
|
|
def delete_default_groups_permissions(apps, schema_editor):
|
|
|
|
Group = apps.get_model("auth", "Group")
|
|
|
|
Group.objects.get(name='Location').delete()
|
|
|
|
Group.objects.get(name='Accounting').delete()
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
|
|
('billard', '0019_merge_20170310_1941'),
|
2018-02-10 15:14:57 +01:00
|
|
|
('sessions', '0001_initial'),
|
2017-04-10 19:38:49 +02:00
|
|
|
]
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(create_default_groups_permissions, delete_default_groups_permissions),
|
|
|
|
]
|