Commit 35de173e authored by Michal Čihař's avatar Michal Čihař

Create anonymous user profile in migration

Doing that in post_migrate signal causes problem with longer migrations
as it's dependencies can not be fulfilled.

Issue #1082
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 4184063f
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-20 16:05
from __future__ import unicode_literals
from django.db import migrations
from weblate.appsettings import ANONYMOUS_USER_NAME
def add_anonymous_profile(apps, schema_editor):
"""Ensure anonymous user has profile"""
User = apps.get_model('auth', 'User')
Profile = apps.get_model('accounts', 'Profile')
anon_user = User.objects.get_or_create(
username=ANONYMOUS_USER_NAME,
defaults={
'is_active': False
}
)[0]
class Migration(migrations.Migration):
dependencies = [
('accounts', '0016_add-api-keys'),
('auth', '0001_initial'),
]
operations = [
migrations.RunPython(add_anonymous_profile),
]
......@@ -968,8 +968,6 @@ def create_groups(update):
username=ANONYMOUS_USER_NAME,
is_active=False,
)
# Ensure anonymous user has profile
Profile.objects.get_or_create(user=anon_user)
if created or update:
anon_user.set_unusable_password()
......
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