realm: Replace allow_message_deleting with delete_own_message_policy.

This commit replaces 'allow_message_deleting' boolean setting
with an integer setting 'delete_own_message_policy'. We have a
separate dropdown now for deciding which user-roles can delete
messages sent by themselves and the time-limit setting droddown
is different.

This new setting has two options - everyone and admins only. Other
options including moderators will be added further.

We also remove the "Never" option from the original time-limit
dropdown, as admins are always allowed to delete message. This
never option resembled the case of only admins being allowed to
delete but this state is now resembled by setting the dropdown
to "admins only" and we also disable the time-limit dropdown in
this case as admins are allowed to delete irrespective of limit.

Note, this setting is only for deleting messages sent by the
deleting user themselves, and only admins are allowed to delete
messages sent by others as before.
This commit is contained in:
sahil839
2021-06-08 17:15:14 +05:30
committed by Tim Abbott
parent b13bfa09c5
commit 909a3cde76
23 changed files with 252 additions and 51 deletions

View File

@@ -0,0 +1,34 @@
# Generated by Django 3.2.4 on 2021-06-09 10:02
from django.db import migrations
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def migrate_to_delete_own_message_policy(
apps: StateApps, schema_editor: DatabaseSchemaEditor
) -> None:
Realm = apps.get_model("zerver", "Realm")
Realm.POLICY_EVERYONE = 5
Realm.POLICY_ADMINS_ONLY = 2
Realm.objects.filter(allow_message_deleting=False).update(
delete_own_message_policy=Realm.POLICY_ADMINS_ONLY
)
Realm.objects.filter(allow_message_deleting=True).update(
delete_own_message_policy=Realm.POLICY_EVERYONE
)
class Migration(migrations.Migration):
dependencies = [
("zerver", "0355_realm_delete_own_message_policy"),
]
operations = [
migrations.RunPython(
migrate_to_delete_own_message_policy,
reverse_code=migrations.RunPython.noop,
elidable=True,
),
]