From 138a67d97e71aec0b961e4d17882db989751a6cc Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Mon, 12 Jun 2023 14:45:29 +0530 Subject: [PATCH] types: Add default_group_name field to GroupPermissionSetting type. This commit adds default_group_name field to GroupPermissionSetting type which will be used to store the name of the default group for that setting which would in most cases be one of the role-based system groups. This will be helpful when we would have multiple settings and we would need to set the defaults while creating realm and streams. --- zerver/lib/types.py | 1 + zerver/models.py | 1 + zerver/views/streams.py | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/zerver/lib/types.py b/zerver/lib/types.py index 430fec2ea9..fc89a665cf 100644 --- a/zerver/lib/types.py +++ b/zerver/lib/types.py @@ -280,3 +280,4 @@ class GroupPermissionSetting: allow_internet_group: bool allow_owners_group: bool allow_nobody_group: bool + default_group_name: str diff --git a/zerver/models.py b/zerver/models.py index 5213265021..5fa5fb184e 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -2643,6 +2643,7 @@ class Stream(models.Model): allow_internet_group=False, allow_owners_group=False, allow_nobody_group=False, + default_group_name=UserGroup.ADMINISTRATORS_GROUP_NAME, ), } diff --git a/zerver/views/streams.py b/zerver/views/streams.py index c4ae4acb38..6fc844d97b 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -591,8 +591,13 @@ def add_subscriptions_backend( allow_nobody_group=False, ) else: + can_remove_subscribers_group_default = Stream.stream_permission_group_settings[ + "can_remove_subscribers_group" + ].default_group_name can_remove_subscribers_group = UserGroup.objects.get( - name="@role:administrators", realm=user_profile.realm, is_system_group=True + name=can_remove_subscribers_group_default, + realm=user_profile.realm, + is_system_group=True, ) for stream_dict in streams_raw: