2019-04-08 19:23:00 +02:00
|
|
|
# Generated by Django 1.11.20 on 2019-04-29 05:29
|
|
|
|
from django.db import migrations, models
|
2022-05-27 23:33:51 +02:00
|
|
|
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
|
2019-04-08 19:23:00 +02:00
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
2020-02-17 17:13:57 +01:00
|
|
|
INVITE_TO_STREAM_POLICY_MEMBERS = 1
|
2021-02-12 08:19:30 +01:00
|
|
|
|
|
|
|
|
2022-05-27 23:33:51 +02:00
|
|
|
def handle_waiting_period(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.INVITE_TO_STREAM_POLICY_WAITING_PERIOD = 3
|
2019-04-08 19:23:00 +02:00
|
|
|
Realm.objects.filter(waiting_period_threshold__gt=0).update(
|
2021-02-12 08:19:30 +01:00
|
|
|
invite_to_stream_policy=Realm.INVITE_TO_STREAM_POLICY_WAITING_PERIOD
|
|
|
|
)
|
|
|
|
|
2019-04-08 19:23:00 +02:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("zerver", "0213_realm_digest_weekday"),
|
2019-04-08 19:23:00 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
2021-02-12 08:20:45 +01:00
|
|
|
model_name="realm",
|
|
|
|
name="invite_to_stream_policy",
|
2020-02-17 17:13:57 +01:00
|
|
|
field=models.PositiveSmallIntegerField(default=INVITE_TO_STREAM_POLICY_MEMBERS),
|
2019-04-08 19:23:00 +02:00
|
|
|
),
|
2021-02-12 08:19:30 +01:00
|
|
|
migrations.RunPython(
|
|
|
|
handle_waiting_period, reverse_code=migrations.RunPython.noop, elidable=True
|
|
|
|
),
|
2019-04-08 19:23:00 +02:00
|
|
|
]
|