Files
zulip/zerver/migrations/0236_remove_illegal_characters_email_full.py
Anders Kaseorg df001db1a9 black: Reformat with Black 23.
Black 23 enforces some slightly more specific rules about empty line
counts and redundant parenthesis removal, but the result is still
compatible with Black 22.

(This does not actually upgrade our Python environment to Black 23
yet.)

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-02 10:40:13 -08:00

31 lines
994 B
Python

# Generated by Django 1.11.20 on 2019-06-28 21:45
from unicodedata import category
from django.db import migrations
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
NAME_INVALID_CHARS = ["*", "`", "\\", ">", '"', "@"]
def remove_name_illegal_chars(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
UserProfile = apps.get_model("zerver", "UserProfile")
for user in UserProfile.objects.all():
stripped = []
for char in user.full_name:
if (char not in NAME_INVALID_CHARS) and (category(char)[0] != "C"):
stripped.append(char)
user.full_name = "".join(stripped)
user.save(update_fields=["full_name"])
class Migration(migrations.Migration):
dependencies = [
("zerver", "0235_userprofile_desktop_icon_count_display"),
]
operations = [
migrations.RunPython(remove_name_illegal_chars, elidable=True),
]