mirror of
https://github.com/boostorg/website-v2.git
synced 2026-01-19 04:42:17 +00:00
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.
34 lines
1.0 KiB
Python
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
|
|
),
|
|
]
|