do_deactivate_realm: Add deactivation_reason kwarg.

It's going to be helpful in the future to record the reason for realm
deactivation.
- For information tracking
- For making a distinction between cases where we can allow realm owners
  to reactivate their realm via a self-serve flow (e.g.
  "owner_request") vs where we can't (ToS abuse).
This commit is contained in:
Mateusz Mandera
2024-05-19 01:30:36 +02:00
committed by Tim Abbott
parent 6af748fa77
commit 27c4e46b30
18 changed files with 103 additions and 35 deletions

View File

@@ -421,11 +421,15 @@ class TestRealmAuditLog(ZulipTestCase):
def test_realm_activation(self) -> None:
realm = get_realm("zulip")
user = self.example_user("desdemona")
do_deactivate_realm(realm, acting_user=user)
do_deactivate_realm(realm, acting_user=user, deactivation_reason="owner_request")
log_entry = RealmAuditLog.objects.get(
realm=realm, event_type=RealmAuditLog.REALM_DEACTIVATED, acting_user=user
)
extra_data = log_entry.extra_data
deactivation_reason = extra_data["deactivation_reason"]
self.assertEqual(deactivation_reason, "owner_request")
self.check_role_count_schema(extra_data[RealmAuditLog.ROLE_COUNT])
do_reactivate_realm(realm)