Commit 620ebe6a authored by Michal Čihař's avatar Michal Čihař

Move AutoGroup creation for Users group to migration

It really can not be done safely in the post_migrate signal as it might
be emitted before the app is fully migrated.

Issue #1082
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 35de173e
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-20 16:12
from __future__ import unicode_literals
from django.db import migrations
def add_users_autogroup(apps, schema_editor):
"""Ensure there is AutoGroup for Users group matching all"""
Group = apps.get_model('auth', 'Group')
AutoGroup = apps.get_model('accounts', 'AutoGroup')
group = Group.objects.get_or_create(name='Users')[0]
if not AutoGroup.objects.filter(group=group).exists():
AutoGroup.objects.create(group=group, match='^.*$')
class Migration(migrations.Migration):
dependencies = [
('accounts', '0017_anonymous_profile'),
]
operations = [
migrations.RunPython(add_users_autogroup, reverse_code=lambda apps, schema_editor: None),
]
...@@ -904,9 +904,6 @@ def create_groups(update): ...@@ -904,9 +904,6 @@ def create_groups(update):
Permission.objects.get(codename='use_mt'), Permission.objects.get(codename='use_mt'),
) )
if not AutoGroup.objects.filter(group=group).exists():
AutoGroup.objects.create(group=group, match='^.*$')
owner_permissions = ( owner_permissions = (
Permission.objects.get(codename='author_translation'), Permission.objects.get(codename='author_translation'),
Permission.objects.get(codename='upload_translation'), Permission.objects.get(codename='upload_translation'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment