Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

models: Add realm.owner_full_content_access and management command.

Shubham Padia264749d9edda
diff --git a/zerver/management/commands/set_owner_full_content_access.py b/zerver/management/commands/set_owner_full_content_access.py
new file mode 100644
index 00000000000..60e77a87226
--- /dev/null
+++ b/zerver/management/commands/set_owner_full_content_access.py
@@ -0,0 +1,42 @@
+from argparse import ArgumentParser
+from typing import Any
+
+from typing_extensions import override
+
+from zerver.lib.management import ZulipBaseCommand
+
+
+class Command(ZulipBaseCommand):
+ help = (
+ "Set the owner_full_content_access flag for a realm. The flag determines "
+ "whether the organization's owner will have the ability to access private "
+ "content in the organization in the Zulip UI."
+ )
+
+ @override
+ def add_arguments(self, parser: ArgumentParser) -> None:
+ toggle_group = parser.add_mutually_exclusive_group(required=True)
+ toggle_group.add_argument(
+ "--enable",
+ action="store_true",
+ help="Set owner_full_content_access to True.",
+ )
+ toggle_group.add_argument(
+ "--disable",
+ action="store_false",
+ help="Set owner_full_content_access to False.",
+ )
+ self.add_realm_args(parser, required=True)
+
+ @override
+ def handle(self, *args: Any, **options: Any) -> None:
+ realm = self.get_realm(options)
+ assert realm is not None # Should be ensured by parser
+
+ owner_full_content_access = options["enable"]
+ realm.owner_full_content_access = owner_full_content_access
+ realm.save(update_fields=["owner_full_content_access"])
+
+ print(
+ f"owner_full_content_access set to {owner_full_content_access} for realm {realm.name} (id={realm.id})."
+ )
diff --git a/zerver/migrations/0762_realm_owner_full_content_access.py b/zerver/migrations/0762_realm_owner_full_content_access.py
new file mode 100644
index 00000000000..80ebed85501
--- /dev/null
+++ b/zerver/migrations/0762_realm_owner_full_content_access.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.7 on 2025-11-27 00:00
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("zerver", "0761_realm_send_channel_events_messages"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="realm",
+ name="owner_full_content_access",
+ field=models.BooleanField(default=False, db_default=False),
+ ),
+ ]
diff --git a/zerver/models/realms.py b/zerver/models/realms.py
index 0af67a78a43..fa092ffffef 100644
--- a/zerver/models/realms.py
+++ b/zerver/models/realms.py
@@ -233,6 +233,11 @@ class Realm(models.Model):
send_welcome_emails = models.BooleanField(default=True)
message_content_allowed_in_email_notifications = models.BooleanField(default=True)
+ # Whether the organization's security policy allows owners to take
+ # actions like full data exports that grant access to all private
+ # content in this organization.
+ owner_full_content_access = models.BooleanField(default=False, db_default=False)
+
topics_policy = models.PositiveSmallIntegerField(
default=RealmTopicsPolicyEnum.allow_empty_topic.value
)