mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	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.
		
			
				
	
	
		
			18 lines
		
	
	
		
			727 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			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."))
 |