Files
zulip/zerver/lib/demo_organizations.py
Lauryn Menard c797c481b3 demo-orgs: Delete expired demo orgs in archive_messages cron job.
Adds delete_expired_demo_organizations to the archive_messages
management command, which is run as a cron job.

Adds "demo_expired" as a `RealmDeactivationReasonType` to be
used for this specific case of calling do_deactivate_realm.

The function loops through non-deactivated realms that have a
demo organization scheduled deletion datetime set that is less
than the current datetime.
2025-06-07 22:53:01 -07:00

18 lines
727 B
Python

from django.utils.translation import gettext as _
from zerver.lib.exceptions import JsonableError
from zerver.models.realms import Realm
def demo_organization_owner_email_exists(realm: Realm) -> bool:
human_owner_emails = set(realm.get_human_owner_users().values_list("delivery_email", flat=True))
return human_owner_emails != {""}
def check_demo_organization_has_set_email(realm: Realm) -> None:
# This should be called after checking that the realm has
# a demo_organization_scheduled_deletion_date set.
assert realm.demo_organization_scheduled_deletion_date is not None
if not demo_organization_owner_email_exists(realm):
raise JsonableError(_("Configure owner account email address."))