models: Add can_access_all_users_group setting.

This commit adds new setting for controlling who can access
all users in the realm which would have "Everyone" and
"Members only" option.

Fixes part of #10970.
This commit is contained in:
Sahil Batra
2023-03-23 20:12:00 +05:30
committed by Tim Abbott
parent f20d427a4d
commit c82bb3ec76
13 changed files with 165 additions and 3 deletions

View File

@@ -445,6 +445,14 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
"UserGroup", on_delete=models.RESTRICT, related_name="+"
)
# on_delete field here is set to RESTRICT because we don't want to allow
# deleting a user group in case it is referenced by this setting.
# We are not using PROTECT since we want to allow deletion of user groups
# when realm itself is deleted.
can_access_all_users_group = models.ForeignKey(
"UserGroup", on_delete=models.RESTRICT, related_name="+"
)
# Who in the organization is allowed to invite other users to streams.
invite_to_stream_policy = models.PositiveSmallIntegerField(default=POLICY_MEMBERS_ONLY)
@@ -814,6 +822,16 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
default_group_name=SystemGroups.ADMINISTRATORS,
id_field_name="create_multiuse_invite_group_id",
),
can_access_all_users_group=GroupPermissionSetting(
require_system_group=True,
allow_internet_group=False,
allow_owners_group=False,
allow_nobody_group=False,
allow_everyone_group=True,
default_group_name=SystemGroups.EVERYONE,
id_field_name="can_access_all_users_group_id",
allowed_system_groups=[SystemGroups.EVERYONE],
),
)
DIGEST_WEEKDAY_VALUES = [0, 1, 2, 3, 4, 5, 6]