forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 zulip#10970.
- Loading branch information
Showing
13 changed files
with
165 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
zerver/migrations/0487_realm_can_access_all_users_group.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.1.7 on 2023-03-23 14:40 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("zerver", "0486_clear_old_data_for_unused_usermessage_flags"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="realm", | ||
name="can_access_all_users_group", | ||
field=models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.RESTRICT, | ||
related_name="+", | ||
to="zerver.usergroup", | ||
), | ||
), | ||
] |
35 changes: 35 additions & 0 deletions
35
zerver/migrations/0488_set_default_value_for_can_access_all_users_group.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 4.2.5 on 2023-09-21 14:00 | ||
|
||
from django.db import migrations | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
from django.db.migrations.state import StateApps | ||
from django.db.models import OuterRef | ||
|
||
|
||
def set_default_value_for_can_access_all_users_group( | ||
apps: StateApps, schema_editor: BaseDatabaseSchemaEditor | ||
) -> None: | ||
Realm = apps.get_model("zerver", "Realm") | ||
UserGroup = apps.get_model("zerver", "UserGroup") | ||
|
||
EVERYONE_GROUP_NAME = "role:everyone" | ||
|
||
Realm.objects.filter(can_access_all_users_group=None).update( | ||
can_access_all_users_group=UserGroup.objects.filter( | ||
name=EVERYONE_GROUP_NAME, realm=OuterRef("id"), is_system_group=True | ||
).values("pk") | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("zerver", "0487_realm_can_access_all_users_group"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
set_default_value_for_can_access_all_users_group, | ||
elidable=True, | ||
reverse_code=migrations.RunPython.noop, | ||
), | ||
] |
22 changes: 22 additions & 0 deletions
22
zerver/migrations/0489_alter_realm_can_access_all_users_group.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 4.2.5 on 2023-09-21 14:07 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("zerver", "0488_set_default_value_for_can_access_all_users_group"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="realm", | ||
name="can_access_all_users_group", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.RESTRICT, | ||
related_name="+", | ||
to="zerver.usergroup", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters