Files
zulip/zerver/migrations/0264_migrate_is_announcement_only.py
Anders Kaseorg 6e4c3e41dc python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00

31 lines
972 B
Python

# Generated by Django 1.11.26 on 2020-01-25 23:47
from django.db import migrations
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def upgrade_stream_post_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
Stream = apps.get_model("zerver", "Stream")
Stream.STREAM_POST_POLICY_EVERYONE = 1
Stream.STREAM_POST_POLICY_ADMINS = 2
Stream.objects.filter(is_announcement_only=False).update(
stream_post_policy=Stream.STREAM_POST_POLICY_EVERYONE
)
Stream.objects.filter(is_announcement_only=True).update(
stream_post_policy=Stream.STREAM_POST_POLICY_ADMINS
)
class Migration(migrations.Migration):
dependencies = [
("zerver", "0263_stream_stream_post_policy"),
]
operations = [
migrations.RunPython(
upgrade_stream_post_policy, reverse_code=migrations.RunPython.noop, elidable=True
),
]