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 ORG_TYPE_CHANGED audit log entries.

Sahil Batraa5bb330a3521
diff --git a/zerver/actions/realm_settings.py b/zerver/actions/realm_settings.py
index 188122f497b..636dade96f2 100644
--- a/zerver/actions/realm_settings.py
+++ b/zerver/actions/realm_settings.py
@@ -807,7 +807,13 @@ def do_change_realm_org_type(
realm=realm,
event_time=timezone_now(),
acting_user=acting_user,
- extra_data={"old_value": old_value, "new_value": org_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: org_type,
+ },
)
event = dict(type="realm", op="update", property="org_type", value=org_type)
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index d308fce98f9..58fec9a7208 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -1369,8 +1369,8 @@ class RealmTest(ZulipTestCase):
).last()
assert realm_audit_log is not None
expected_extra_data = {
- "old_value": Realm.ORG_TYPES["business"]["id"],
- "new_value": Realm.ORG_TYPES["government"]["id"],
+ RealmAuditLog.OLD_VALUE: Realm.ORG_TYPES["business"]["id"],
+ RealmAuditLog.NEW_VALUE: Realm.ORG_TYPES["government"]["id"],
}
self.assertEqual(realm_audit_log.extra_data, expected_extra_data)
self.assertEqual(realm_audit_log.acting_user, iago)