Skip to content
Snippets Groups Projects
Commit 1c0b423c authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Merge branch 'fix-display-name-migration' into 'master'

Split the user display name migration

Closes #586

See merge request !1133
parents 174e435f 3165a4ab
No related branches found
No related tags found
1 merge request!1133Split the user display name migration
......@@ -3,16 +3,6 @@
from django.db import migrations, models
def get_name_from_email(apps, schema_editor):
User = apps.get_model('users', 'User')
for user in User.objects.all():
try:
user.display_name = user.email.split('@')[0].replace('.', ' ').title()
except Exception:
user.display_name = user.email
user.save()
class Migration(migrations.Migration):
dependencies = [
......@@ -25,10 +15,5 @@ class Migration(migrations.Migration):
name='display_name',
field=models.CharField(default='default name', max_length=120),
preserve_default=False,
),
migrations.RunPython(
get_name_from_email,
reverse_code=migrations.RunPython.noop,
elidable=True
)
]
from django.db import migrations
def get_name_from_email(apps, schema_editor):
User = apps.get_model('users', 'User')
for user in User.objects.filter(display_name='default name'):
try:
user.display_name = user.email.split('@')[0].replace('.', ' ').title()
except Exception:
user.display_name = user.email
user.save()
class Migration(migrations.Migration):
dependencies = [
('users', '0007_user_display_name'),
]
operations = [
migrations.RunPython(
get_name_from_email,
reverse_code=migrations.RunPython.noop,
elidable=True
)
]
......@@ -10,7 +10,7 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0007_user_display_name'),
('users', '0008_populate_user_display_name'),
]
operations = [
......
......@@ -12,7 +12,7 @@ class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('users', '0008_membership_uuid_and_validation'),
('users', '0009_membership_uuid_and_validation'),
]
operations = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment