2020-06-24 20:38:41 +02:00
|
|
|
# Generated by Django 2.2.13 on 2020-06-21 21:13
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
|
|
|
|
|
|
|
def update_invite_as_dict_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
PreregistrationUser = apps.get_model("zerver", "PreregistrationUser")
|
|
|
|
MultiuseInvite = apps.get_model("zerver", "MultiuseInvite")
|
2020-06-24 20:38:41 +02:00
|
|
|
|
|
|
|
OLD_INVITE_AS_DICT = dict(
|
2021-02-12 08:19:30 +01:00
|
|
|
MEMBER=1,
|
|
|
|
REALM_ADMIN=2,
|
|
|
|
GUEST_USER=3,
|
|
|
|
REALM_OWNER=4,
|
2020-06-24 20:38:41 +02:00
|
|
|
)
|
|
|
|
NEW_INVITE_AS_DICT = dict(
|
2021-02-12 08:19:30 +01:00
|
|
|
REALM_OWNER=100,
|
|
|
|
REALM_ADMIN=200,
|
|
|
|
MEMBER=400,
|
|
|
|
GUEST_USER=600,
|
|
|
|
)
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT["REALM_OWNER"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["REALM_OWNER"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2021-02-12 08:20:45 +01:00
|
|
|
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT["REALM_ADMIN"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["REALM_ADMIN"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2021-02-12 08:20:45 +01:00
|
|
|
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT["MEMBER"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["MEMBER"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2021-02-12 08:20:45 +01:00
|
|
|
PreregistrationUser.objects.filter(invited_as=OLD_INVITE_AS_DICT["GUEST_USER"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["GUEST_USER"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT["REALM_OWNER"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["REALM_OWNER"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2021-02-12 08:20:45 +01:00
|
|
|
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT["REALM_ADMIN"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["REALM_ADMIN"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2021-02-12 08:20:45 +01:00
|
|
|
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT["MEMBER"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["MEMBER"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2021-02-12 08:20:45 +01:00
|
|
|
MultiuseInvite.objects.filter(invited_as=OLD_INVITE_AS_DICT["GUEST_USER"]).update(
|
|
|
|
invited_as=NEW_INVITE_AS_DICT["GUEST_USER"]
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
|
|
|
|
2020-06-24 20:38:41 +02:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("zerver", "0292_update_default_value_of_invited_as"),
|
2020-06-24 20:38:41 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
2021-02-12 08:19:30 +01:00
|
|
|
migrations.RunPython(
|
|
|
|
update_invite_as_dict_values, reverse_code=migrations.RunPython.noop, elidable=True
|
|
|
|
),
|
2020-06-24 20:38:41 +02:00
|
|
|
]
|