mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-07 07:36:20 +01:00
Correct migration syntax.
This commit is contained in:
@@ -5,20 +5,10 @@ from __future__ import unicode_literals
|
||||
from django.db import migrations
|
||||
from django.conf import settings
|
||||
|
||||
def create_groups(apps, schema_editor):
|
||||
Group = apps.get_model('auth', 'Group')
|
||||
Group.objects.get_or_create(name=settings.DEFAULT_AUTH_GROUP)
|
||||
Group.objects.get_or_create(name=settings.DEFAULT_BLUE_GROUP)
|
||||
|
||||
def reverse(apps, schema_editor):
|
||||
pass
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('groupmanagement', '0002_auto_20160906_2354'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(create_groups, reverse)
|
||||
]
|
||||
operations = []
|
||||
|
||||
@@ -12,23 +12,6 @@ import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def add_default_member_permission(apps, schema_editor):
|
||||
for app_config in apps.get_app_configs():
|
||||
app_config.models_module = True
|
||||
create_permissions(app_config, apps=apps, verbosity=0)
|
||||
app_config.models_module = None
|
||||
|
||||
Group = apps.get_model("auth", "Group")
|
||||
Permission = apps.get_model("auth", "Permission")
|
||||
|
||||
try:
|
||||
perm = Permission.objects.get(codename='request_groups', name='Can request non-public groups')
|
||||
group = Group.objects.get(name=getattr(settings, str('DEFAULT_AUTH_GROUP'), 'Member'))
|
||||
group.permissions.add(perm)
|
||||
except ObjectDoesNotExist:
|
||||
logger.warning('Failed to add default request_groups permission to Member group')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@@ -40,5 +23,4 @@ class Migration(migrations.Migration):
|
||||
name='authgroup',
|
||||
options={'permissions': (('request_groups', 'Can request non-public groups'),)},
|
||||
),
|
||||
migrations.RunPython(add_default_member_permission),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user