35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
# Generated by Django 4.2.7 on 2023-11-26 00:16
|
|
|
|
from django.conf import settings
|
|
from django.db import migrations
|
|
from django.contrib.auth.models import Permission, Group
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
initial = True
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
('authentication', '0001_initial'),
|
|
('inventory', '0003_alter_item_options'),
|
|
('tickets', '0003_alter_issuethread_options'),
|
|
]
|
|
|
|
def create_groups(apps, schema_editor):
|
|
admins = Group.objects.create(name='Admin')
|
|
orga = Group.objects.create(name='Orga')
|
|
team = Group.objects.create(name='Team')
|
|
users = Group.objects.create(name='User')
|
|
admins.permissions.add(*Permission.objects.all())
|
|
users.permissions.add(*Permission.objects.filter(codename__in=
|
|
['view_item', 'add_item', 'change_item', 'match_item']))
|
|
team.permissions.add(*Permission.objects.filter(codename__in=
|
|
['delete_item', 'view_issuethread', 'add_issuethread',
|
|
'change_issuethread', 'delete_issuethread', 'send_mail']),
|
|
*users.permissions.all())
|
|
orga.permissions.add(*Permission.objects.filter(codename__in=['add_event']),
|
|
*team.permissions.all())
|
|
|
|
operations = [
|
|
migrations.RunPython(create_groups),
|
|
]
|