mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 20:13:46 +00:00 
			
		
		
		
	support: Create RealmAuditLog when updating realm_subdomain.
This commit is contained in:
		
				
					committed by
					
						 Tim Abbott
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							80c9243c6a
						
					
				
				
					commit
					47e478945b
				
			| @@ -1035,11 +1035,20 @@ def do_reactivate_realm(realm: Realm) -> None: | ||||
|     ) | ||||
|  | ||||
|  | ||||
| def do_change_realm_subdomain(realm: Realm, new_subdomain: str) -> None: | ||||
| def do_change_realm_subdomain( | ||||
|     realm: Realm, new_subdomain: str, *, acting_user: Optional[UserProfile] | ||||
| ) -> None: | ||||
|     old_subdomain = realm.subdomain | ||||
|     old_uri = realm.uri | ||||
|     realm.string_id = new_subdomain | ||||
|     realm.save(update_fields=["string_id"]) | ||||
|     RealmAuditLog.objects.create( | ||||
|         realm=realm, | ||||
|         event_type=RealmAuditLog.REALM_SUBDOMAIN_CHANGED, | ||||
|         event_time=timezone_now(), | ||||
|         acting_user=acting_user, | ||||
|         extra_data={"old_subdomain": old_subdomain, "new_subdomain": new_subdomain}, | ||||
|     ) | ||||
|  | ||||
|     # If a realm if being renamed multiple times, we should find all the placeholder | ||||
|     # realms and reset their deactivated_redirect field to point to the new realm uri | ||||
|   | ||||
		Reference in New Issue
	
	Block a user