Update permissions and groups
This commit is contained in:
		
							
								
								
									
										32
									
								
								billard/migrations/0020_auto_20170410_1853.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								billard/migrations/0020_auto_20170410_1853.py
									
									
									
									
									
										Normal file
									
								
							@@ -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),
 | 
			
		||||
    ]
 | 
			
		||||
		Reference in New Issue
	
	Block a user