From 0f324b8a17e4e8211d17f4dda41a1320a09a124d Mon Sep 17 00:00:00 2001 From: Alexander Werner Date: Mon, 10 Apr 2017 19:38:49 +0200 Subject: [PATCH] Update permissions and groups --- billard/migrations/0020_auto_20170410_1853.py | 32 +++++++++++++++++++ billard/templates/billard/base.html | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 billard/migrations/0020_auto_20170410_1853.py diff --git a/billard/migrations/0020_auto_20170410_1853.py b/billard/migrations/0020_auto_20170410_1853.py new file mode 100644 index 0000000..901e580 --- /dev/null +++ b/billard/migrations/0020_auto_20170410_1853.py @@ -0,0 +1,32 @@ +# -*- 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 + +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")) + +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'), + ] + operations = [ + migrations.RunPython(create_default_groups_permissions, delete_default_groups_permissions), + ] diff --git a/billard/templates/billard/base.html b/billard/templates/billard/base.html index efe6f2d..07d5217 100644 --- a/billard/templates/billard/base.html +++ b/billard/templates/billard/base.html @@ -29,7 +29,9 @@