realm_audit_log: Explicitly stringify dict before insertion.

`extra_data` as a `TextField` expects a `str`, but we had been passing
`dict` instead. This is a temporary solution before #18391 to fix the
type annotation.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-25 08:54:24 -04:00 committed by Tim Abbott
parent 4be2f0ed10
commit ad17096c9c
5 changed files with 9 additions and 13 deletions

View File

@ -633,7 +633,7 @@ def do_change_remote_server_plan_type(remote_server: RemoteZulipServer, plan_typ
event_type=RealmAuditLog.REMOTE_SERVER_PLAN_TYPE_CHANGED,
server=remote_server,
event_time=timezone_now(),
extra_data={"old_value": old_value, "new_value": plan_type},
extra_data=str({"old_value": old_value, "new_value": plan_type}),
)
@ -951,7 +951,7 @@ def attach_discount_to_realm(
acting_user=acting_user,
event_type=RealmAuditLog.REALM_DISCOUNT_CHANGED,
event_time=timezone_now(),
extra_data={"old_discount": old_discount, "new_discount": discount},
extra_data=str({"old_discount": old_discount, "new_discount": discount}),
)
@ -966,9 +966,7 @@ def update_sponsorship_status(
acting_user=acting_user,
event_type=RealmAuditLog.REALM_SPONSORSHIP_PENDING_STATUS_CHANGED,
event_time=timezone_now(),
extra_data={
"sponsorship_pending": sponsorship_pending,
},
extra_data=str({"sponsorship_pending": sponsorship_pending}),
)
@ -1213,7 +1211,5 @@ def update_billing_method_of_current_plan(
acting_user=acting_user,
event_type=RealmAuditLog.REALM_BILLING_METHOD_CHANGED,
event_time=timezone_now(),
extra_data={
"charge_automatically": charge_automatically,
},
extra_data=str({"charge_automatically": charge_automatically}),
)

View File

@ -57,7 +57,7 @@ def do_change_realm_subdomain(
event_type=RealmAuditLog.REALM_SUBDOMAIN_CHANGED,
event_time=timezone_now(),
acting_user=acting_user,
extra_data={"old_subdomain": old_subdomain, "new_subdomain": new_subdomain},
extra_data=str({"old_subdomain": old_subdomain, "new_subdomain": new_subdomain}),
)
# If a realm if being renamed multiple times, we should find all the placeholder

View File

@ -20,7 +20,7 @@ def do_change_icon_source(
RealmAuditLog.objects.create(
realm=realm,
event_type=RealmAuditLog.REALM_ICON_SOURCE_CHANGED,
extra_data={"icon_source": icon_source, "icon_version": realm.icon_version},
extra_data=str({"icon_source": icon_source, "icon_version": realm.icon_version}),
event_time=event_time,
acting_user=acting_user,
)

View File

@ -400,7 +400,7 @@ 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=str({"old_value": old_value, "new_value": org_type}),
)
event = dict(type="realm", op="update", property="org_type", value=org_type)
@ -419,7 +419,7 @@ 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=str({"old_value": old_value, "new_value": plan_type}),
)
if plan_type == Realm.PLAN_TYPE_PLUS:

View File

@ -300,7 +300,7 @@ def do_change_avatar_fields(
realm=user_profile.realm,
modified_user=user_profile,
event_type=RealmAuditLog.USER_AVATAR_SOURCE_CHANGED,
extra_data={"avatar_source": avatar_source},
extra_data=str({"avatar_source": avatar_source}),
event_time=event_time,
acting_user=acting_user,
)