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.
This commit is contained in:
Sahil Batra
2023-06-12 14:45:29 +05:30
committed by Tim Abbott
parent b6d1e56cac
commit 138a67d97e
3 changed files with 8 additions and 1 deletions

View File

@@ -280,3 +280,4 @@ class GroupPermissionSetting:
allow_internet_group: bool
allow_owners_group: bool
allow_nobody_group: bool
default_group_name: str

View File

@@ -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,
),
}

View File

@@ -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: