realm: Removed WILDCARD_MENTION_POLICY_STREAM_ADMINS option.

This commit removes WILDCARD_MENTION_POLICY_STREAM_ADMINS
option of wildcard_mention_policy since we are not moving
forward with stream administrator concept and instead working
on new permssions model as per #19525.

We also add a migration to change wildcard_mention_policy of
existing realms to WILDCARD_MENTION_POLICY_ADMINS. This change
is fine since we were already treating both the setting values
as same as stream admin concept was not implemented completely.
This commit is contained in:
Sahil Batra 2022-07-05 18:05:17 +05:30 committed by Tim Abbott
parent d31fc27912
commit 83383090f9
6 changed files with 42 additions and 23 deletions

View File

@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 6.0
**Feature level 133**
* [`POST /register`](/api/register-queue), `PATCH /realm`: Removed
stream administrators option from `wildcard_mention_policy` setting.
**Feature level 132**
* [`GET /streams/{stream_id}`](/api/get-stream-by-id):

View File

@ -1605,10 +1605,6 @@ def wildcard_mention_allowed(sender: UserProfile, stream: Stream) -> bool:
if realm.wildcard_mention_policy == Realm.WILDCARD_MENTION_POLICY_MODERATORS:
return sender.is_realm_admin or sender.is_moderator
if realm.wildcard_mention_policy == Realm.WILDCARD_MENTION_POLICY_STREAM_ADMINS:
# TODO: Change this when we implement stream administrators
return sender.is_realm_admin
if realm.wildcard_mention_policy == Realm.WILDCARD_MENTION_POLICY_FULL_MEMBERS:
return sender.is_realm_admin or (not sender.is_provisional_member and not sender.is_guest)

View File

@ -0,0 +1,32 @@
# Generated by Django 3.2.13 on 2022-07-05 12:23
from django.db import migrations, models
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
def fix_wildcard_mention_policy_stream_admins_value(
apps: StateApps, schema_editor: BaseDatabaseSchemaEditor
) -> None:
Realm = apps.get_model("zerver", "Realm")
WILDCARD_MENTION_POLICY_STREAM_ADMINS = 4
WILDCARD_MENTION_POLICY_ADMINS = 5
Realm.objects.filter(wildcard_mention_policy=WILDCARD_MENTION_POLICY_STREAM_ADMINS).update(
wildcard_mention_policy=WILDCARD_MENTION_POLICY_ADMINS
)
class Migration(migrations.Migration):
dependencies = [
("zerver", "0394_alter_realm_want_advertise_in_communities_directory"),
]
operations = [
migrations.AlterField(
model_name="realm",
name="wildcard_mention_policy",
field=models.PositiveSmallIntegerField(default=5),
),
migrations.RunPython(fix_wildcard_mention_policy_stream_admins_value, elidable=True),
]

View File

@ -414,18 +414,16 @@ class Realm(models.Model):
WILDCARD_MENTION_POLICY_EVERYONE = 1
WILDCARD_MENTION_POLICY_MEMBERS = 2
WILDCARD_MENTION_POLICY_FULL_MEMBERS = 3
WILDCARD_MENTION_POLICY_STREAM_ADMINS = 4
WILDCARD_MENTION_POLICY_ADMINS = 5
WILDCARD_MENTION_POLICY_NOBODY = 6
WILDCARD_MENTION_POLICY_MODERATORS = 7
wildcard_mention_policy: int = models.PositiveSmallIntegerField(
default=WILDCARD_MENTION_POLICY_STREAM_ADMINS,
default=WILDCARD_MENTION_POLICY_ADMINS,
)
WILDCARD_MENTION_POLICY_TYPES = [
WILDCARD_MENTION_POLICY_EVERYONE,
WILDCARD_MENTION_POLICY_MEMBERS,
WILDCARD_MENTION_POLICY_FULL_MEMBERS,
WILDCARD_MENTION_POLICY_STREAM_ADMINS,
WILDCARD_MENTION_POLICY_ADMINS,
WILDCARD_MENTION_POLICY_NOBODY,
WILDCARD_MENTION_POLICY_MODERATORS,

View File

@ -4051,7 +4051,6 @@ paths:
- 1 => Any user can use wildcard mentions in large streams.
- 2 => Only members can use wildcard mentions in large streams.
- 3 => Only [full members][calc-full-member] can use wildcard mentions in large streams.
- 4 => Only stream and organization administrators can use wildcard mentions in large streams.
- 5 => Only organization administrators can use wildcard mentions in large streams.
- 6 => Nobody can use wildcard mentions in large streams.
- 7 => Only organization administrators and moderators can use wildcard mentions in large streams.
@ -4060,7 +4059,8 @@ paths:
mentions in large streams, even when permitted to do so.
**Changes**: New in Zulip 4.0 (feature level 33). Moderators option added in
Zulip 4.0 (feature level 62).
Zulip 4.0 (feature level 62). Stream administrators option removed in
Zulip 6.0 (feature level 133).
[permission-level]: /api/roles-and-permissions#permission-levels
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
@ -10889,7 +10889,6 @@ paths:
- 1 => Any user can use wildcard mentions in large streams.
- 2 => Only members can use wildcard mentions in large streams.
- 3 => Only [full members][calc-full-member] can use wildcard mentions in large streams.
- 4 => Only stream and organization administrators can use wildcard mentions in large streams.
- 5 => Only organization administrators can use wildcard mentions in large streams.
- 6 => Nobody can use wildcard mentions in large streams.
- 7 => Only organization administrators and moderators can use wildcard mentions in large streams.
@ -10898,7 +10897,8 @@ paths:
mentions in large streams, even when permitted to do so.
**Changes**: New in Zulip 4.0 (feature level 33). Moderators option added in
Zulip 4.0 (feature level 62).
Zulip 4.0 (feature level 62). Stream administrators option removed in
Zulip 6.0 (feature level 133).
[permission-level]: /api/roles-and-permissions#permission-levels
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member

View File

@ -1843,18 +1843,6 @@ class StreamMessagesTest(ZulipTestCase):
cordelia.save()
self.send_and_verify_wildcard_mention_message("cordelia")
do_set_realm_property(
realm,
"wildcard_mention_policy",
Realm.WILDCARD_MENTION_POLICY_STREAM_ADMINS,
acting_user=None,
)
# TODO: Change this when we implement stream administrators
self.send_and_verify_wildcard_mention_message("cordelia", test_fails=True)
# There is no restriction on small streams.
self.send_and_verify_wildcard_mention_message("cordelia", sub_count=10)
self.send_and_verify_wildcard_mention_message("iago")
do_set_realm_property(
realm,
"wildcard_mention_policy",