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.

realm: Fix extra_data for REALM_PLAN_TYPE_CHANGED audit log entries.

Sahil Batraece786760219
diff --git a/zerver/actions/realm_settings.py b/zerver/actions/realm_settings.py
index 636dade96f2..87b017b4155 100644
--- a/zerver/actions/realm_settings.py
+++ b/zerver/actions/realm_settings.py
@@ -893,7 +893,13 @@ def do_change_realm_plan_type(
realm=realm,
event_time=timezone_now(),
acting_user=acting_user,
- extra_data={"old_value": old_value, "new_value": plan_type},
+ extra_data={
+ # Prior to Zulip 12.0, RealmAuditLog entries for this
+ # incorrectly used the strings "old_value" and "new_value"
+ # as keys here.
+ RealmAuditLog.OLD_VALUE: old_value,
+ RealmAuditLog.NEW_VALUE: plan_type,
+ },
)
realm.max_invites = get_default_max_invites_for_realm_plan_type(plan_type)
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 58fec9a7208..6f46bdf0c0a 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -1539,8 +1539,8 @@ class RealmTest(ZulipTestCase):
).last()
assert realm_audit_log is not None
expected_extra_data = {
- "old_value": Realm.PLAN_TYPE_SELF_HOSTED,
- "new_value": Realm.PLAN_TYPE_STANDARD,
+ RealmAuditLog.OLD_VALUE: Realm.PLAN_TYPE_SELF_HOSTED,
+ RealmAuditLog.NEW_VALUE: Realm.PLAN_TYPE_STANDARD,
}
self.assertEqual(realm_audit_log.extra_data, expected_extra_data)
self.assertEqual(realm_audit_log.acting_user, iago)