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.

models: Rename setting-changed RealmAuditLog entry.

Tim Abbottfecdc234bff8
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index 6288707eb09..8c3c954903c 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -5052,9 +5052,12 @@ def do_change_notification_settings(
"value": setting_value,
}
event_time = timezone_now()
+
+ # Prior to all personal settings being managed by property_types,
+ # these were only created for notification settings.
RealmAuditLog.objects.create(
realm=user_profile.realm,
- event_type=RealmAuditLog.USER_NOTIFICATION_SETTINGS_CHANGED,
+ event_type=RealmAuditLog.USER_SETTING_CHANGED,
event_time=event_time,
acting_user=acting_user,
modified_user=user_profile,
diff --git a/zerver/migrations/0298_fix_realmauditlog_format.py b/zerver/migrations/0298_fix_realmauditlog_format.py
index e41b669e0a8..f0afa96f016 100644
--- a/zerver/migrations/0298_fix_realmauditlog_format.py
+++ b/zerver/migrations/0298_fix_realmauditlog_format.py
@@ -35,6 +35,10 @@ def update_realmauditlog_values(apps: StateApps, schema_editor: DatabaseSchemaEd
USER_DEFAULT_SENDING_STREAM_CHANGED = 129
USER_DEFAULT_REGISTER_STREAM_CHANGED = 130
USER_DEFAULT_ALL_PUBLIC_STREAMS_CHANGED = 131
+ # Note that this was renamed to USER_SETTING_CHANGED sometime
+ # after this migration; we preserve the original name here to
+ # highlight that as of this migration, only notification settings
+ # had RealmAuditLog entries for changes.
USER_NOTIFICATION_SETTINGS_CHANGED = 132
REALM_PROPERTY_CHANGED = 207
SUBSCRIPTION_PROPERTY_CHANGED = 304
diff --git a/zerver/models.py b/zerver/models.py
index 498bda0a235..db7cae83528 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -3598,7 +3598,7 @@ class AbstractRealmAuditLog(models.Model):
USER_DEFAULT_SENDING_STREAM_CHANGED = 129
USER_DEFAULT_REGISTER_STREAM_CHANGED = 130
USER_DEFAULT_ALL_PUBLIC_STREAMS_CHANGED = 131
- USER_NOTIFICATION_SETTINGS_CHANGED = 132
+ USER_SETTING_CHANGED = 132
USER_DIGEST_EMAIL_CREATED = 133
REALM_DEACTIVATED = 201
diff --git a/zerver/tests/test_audit_log.py b/zerver/tests/test_audit_log.py
index c0fe4c00df6..d8e6177fca9 100644
--- a/zerver/tests/test_audit_log.py
+++ b/zerver/tests/test_audit_log.py
@@ -648,7 +648,7 @@ class TestRealmAuditLog(ZulipTestCase):
self.assertEqual(
RealmAuditLog.objects.filter(
realm=user.realm,
- event_type=RealmAuditLog.USER_NOTIFICATION_SETTINGS_CHANGED,
+ event_type=RealmAuditLog.USER_SETTING_CHANGED,
event_time__gte=now,
acting_user=user,
modified_user=user,