Debian Codegraph @

allauth/account/migrations/0006_emailaddress_lower.py

raw
1 from django.conf import settings
2 from django.db import migrations
3 from django.db.models.functions import Lower
4
5 from allauth.account import app_settings
6
7
8 def forwards(apps, schema_editor):
9 EmailAddress = apps.get_model("account.EmailAddress")
10 User = apps.get_model(settings.AUTH_USER_MODEL)
11 EmailAddress.objects.all().exclude(email=Lower("email")).update(
12 email=Lower("email")
13 )
14 email_field = app_settings.USER_MODEL_EMAIL_FIELD
15 if email_field:
16 User.objects.all().exclude(**{email_field: Lower(email_field)}).update(
17 **{email_field: Lower(email_field)}
18 )
19
20
21 class Migration(migrations.Migration):
22 dependencies = [
23 ("account", "0005_emailaddress_idx_upper_email"),
24 ]
25
26 operations = [migrations.RunPython(forwards, migrations.RunPython.noop)]