mirror of https://github.com/zulip/zulip.git
user_settings: Create RealmAuditLog entries for all user settings.
We previously created RealmAuditLog entries for user notification settings only. This commit changes the code to create entries for all user settings. We cannot backfill the entries since we don't have the data to do that.
This commit is contained in:
parent
0c46bbdf9f
commit
ce562c4820
|
@ -415,12 +415,6 @@ def do_change_user_setting(
|
||||||
# TODO: Move these database actions into a transaction.atomic block.
|
# TODO: Move these database actions into a transaction.atomic block.
|
||||||
user_profile.save(update_fields=[setting_name])
|
user_profile.save(update_fields=[setting_name])
|
||||||
|
|
||||||
if setting_name in UserProfile.notification_setting_types:
|
|
||||||
# Prior to all personal settings being managed by property_types,
|
|
||||||
# these were only created for notification settings.
|
|
||||||
#
|
|
||||||
# TODO: Start creating these for all settings, and do a
|
|
||||||
# backfilled=True migration.
|
|
||||||
RealmAuditLog.objects.create(
|
RealmAuditLog.objects.create(
|
||||||
realm=user_profile.realm,
|
realm=user_profile.realm,
|
||||||
event_type=RealmAuditLog.USER_SETTING_CHANGED,
|
event_type=RealmAuditLog.USER_SETTING_CHANGED,
|
||||||
|
@ -435,6 +429,7 @@ def do_change_user_setting(
|
||||||
}
|
}
|
||||||
).decode(),
|
).decode(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Disabling digest emails should clear a user's email queue
|
# Disabling digest emails should clear a user's email queue
|
||||||
if setting_name == "enable_digest_emails" and not setting_value:
|
if setting_name == "enable_digest_emails" and not setting_value:
|
||||||
clear_scheduled_emails(user_profile.id, ScheduledEmail.DIGEST)
|
clear_scheduled_emails(user_profile.id, ScheduledEmail.DIGEST)
|
||||||
|
|
|
@ -670,13 +670,20 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(stream.name, "updated name")
|
self.assertEqual(stream.name, "updated name")
|
||||||
|
|
||||||
def test_change_notification_settings(self) -> None:
|
def test_change_user_settings(self) -> None:
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
value: Union[bool, int, str]
|
value: Union[bool, int, str]
|
||||||
for setting, v in user.notification_setting_types.items():
|
test_values = dict(
|
||||||
if setting == "notification_sound":
|
default_language="de",
|
||||||
value = "ding"
|
default_view="all_messages",
|
||||||
elif setting == "desktop_icon_count_display":
|
emojiset="twitter",
|
||||||
|
notification_sound="ding",
|
||||||
|
)
|
||||||
|
|
||||||
|
for setting, setting_type in user.property_types.items():
|
||||||
|
if setting in test_values:
|
||||||
|
value = test_values[setting]
|
||||||
|
elif setting_type is int:
|
||||||
value = 3
|
value = 3
|
||||||
else:
|
else:
|
||||||
value = False
|
value = False
|
||||||
|
|
Loading…
Reference in New Issue