2019-05-06 16:34:31 +02:00
|
|
|
# Generated by Django 1.11.20 on 2019-05-06 13:15
|
|
|
|
|
|
|
|
from django.db import migrations
|
2023-03-04 01:40:40 +01:00
|
|
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
2019-05-06 16:34:31 +02:00
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2022-05-27 23:33:51 +02:00
|
|
|
def upgrade_create_stream_policy(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
Realm = apps.get_model("zerver", "Realm")
|
2020-02-17 17:13:57 +01:00
|
|
|
Realm.CREATE_STREAM_POLICY_MEMBERS = 1
|
|
|
|
Realm.CREATE_STREAM_POLICY_ADMINS = 2
|
|
|
|
Realm.CREATE_STREAM_POLICY_WAITING_PERIOD = 3
|
2021-02-12 08:19:30 +01:00
|
|
|
Realm.objects.filter(waiting_period_threshold__exact=0).filter(
|
|
|
|
create_stream_by_admins_only=False
|
|
|
|
).update(create_stream_policy=Realm.CREATE_STREAM_POLICY_MEMBERS)
|
|
|
|
Realm.objects.filter(create_stream_by_admins_only=True).update(
|
|
|
|
create_stream_policy=Realm.CREATE_STREAM_POLICY_ADMINS
|
|
|
|
)
|
|
|
|
Realm.objects.filter(waiting_period_threshold__gt=0).filter(
|
|
|
|
create_stream_by_admins_only=False
|
|
|
|
).update(create_stream_policy=Realm.CREATE_STREAM_POLICY_WAITING_PERIOD)
|
|
|
|
|
2019-05-06 16:34:31 +02:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("zerver", "0216_add_create_stream_policy"),
|
2019-05-06 16:34:31 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
2021-02-12 08:19:30 +01:00
|
|
|
migrations.RunPython(
|
|
|
|
upgrade_create_stream_policy, reverse_code=migrations.RunPython.noop, elidable=True
|
|
|
|
),
|
2019-05-06 16:34:31 +02:00
|
|
|
]
|