Files
website-v2/users/migrations/0005_auto_20211121_0908.py
Natalia 80eae90184 Initial model for User's preferences, specifically for email notifications.
Part of #343. The news' notifications module was also changed to the user
preferences is honored when sending news emails.

Also exclude migrations from the black check.
2023-06-16 13:00:16 -03:00

34 lines
1.0 KiB
Python

# Generated by Django 3.2.2 on 2021-11-21 09:08
from django.db import migrations
from django.contrib.auth.models import Group, Permission
from django.core.management import BaseCommand
from django.contrib.contenttypes.models import ContentType
def gen_version_manager_group(apps, schema_editor):
from versions.models import Version
new_group, created = Group.objects.get_or_create(name="version_manager")
# Code to add permission to group ???
ct = ContentType.objects.get_for_model(Version)
# Now what - Say I want to add 'Can add version' permission to new_group?
permission, created = Permission.objects.get_or_create(
codename="can_add_version", name="Can add version", content_type=ct
)
new_group.permissions.add(permission)
class Migration(migrations.Migration):
dependencies = [
("users", "0004_auto_20211105_0915"),
]
operations = [
migrations.RunPython(
gen_version_manager_group, reverse_code=migrations.RunPython.noop
),
]