mirror of https://github.com/zulip/zulip.git
models: Add USER_EMAIL_CHANGED event type constant to RealmAuditLog.
This commit is contained in:
parent
75ed3f92e2
commit
83ff688bb6
|
@ -797,7 +797,7 @@ def do_change_user_email(user_profile: UserProfile, new_email: str) -> None:
|
||||||
active_user_ids(user_profile.realm_id))
|
active_user_ids(user_profile.realm_id))
|
||||||
event_time = timezone_now()
|
event_time = timezone_now()
|
||||||
RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=user_profile,
|
RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=user_profile,
|
||||||
modified_user=user_profile, event_type='user_email_changed',
|
modified_user=user_profile, event_type=RealmAuditLog.USER_EMAIL_CHANGED,
|
||||||
event_time=event_time)
|
event_time=event_time)
|
||||||
|
|
||||||
def do_start_email_change_process(user_profile: UserProfile, new_email: str) -> None:
|
def do_start_email_change_process(user_profile: UserProfile, new_email: str) -> None:
|
||||||
|
|
|
@ -1969,6 +1969,7 @@ class RealmAuditLog(models.Model):
|
||||||
USER_CHANGE_PASSWORD = 'user_change_password'
|
USER_CHANGE_PASSWORD = 'user_change_password'
|
||||||
USER_CHANGE_AVATAR_SOURCE = 'user_change_avatar_source'
|
USER_CHANGE_AVATAR_SOURCE = 'user_change_avatar_source'
|
||||||
USER_FULL_NAME_CHANGED = 'user_full_name_changed'
|
USER_FULL_NAME_CHANGED = 'user_full_name_changed'
|
||||||
|
USER_EMAIL_CHANGED = 'user_email_changed'
|
||||||
|
|
||||||
event_type = models.CharField(max_length=40) # type: str
|
event_type = models.CharField(max_length=40) # type: str
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,12 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||||
user = self.example_user('hamlet')
|
user = self.example_user('hamlet')
|
||||||
email = 'test@example.com'
|
email = 'test@example.com'
|
||||||
do_change_user_email(user, email)
|
do_change_user_email(user, email)
|
||||||
self.assertEqual(RealmAuditLog.objects.filter(event_type='user_email_changed',
|
self.assertEqual(RealmAuditLog.objects.filter(event_type=RealmAuditLog.USER_EMAIL_CHANGED,
|
||||||
event_time__gte=now).count(), 1)
|
event_time__gte=now).count(), 1)
|
||||||
self.assertEqual(email, user.email)
|
self.assertEqual(email, user.email)
|
||||||
|
|
||||||
# Test the RealmAuditLog stringification
|
# Test the RealmAuditLog stringification
|
||||||
audit_entry = RealmAuditLog.objects.get(event_type='user_email_changed', event_time__gte=now)
|
audit_entry = RealmAuditLog.objects.get(event_type=RealmAuditLog.USER_EMAIL_CHANGED, event_time__gte=now)
|
||||||
self.assertTrue(str(audit_entry).startswith("<RealmAuditLog: <UserProfile: test@example.com <Realm: zulip 1>> user_email_changed "))
|
self.assertTrue(str(audit_entry).startswith("<RealmAuditLog: <UserProfile: test@example.com <Realm: zulip 1>> user_email_changed "))
|
||||||
|
|
||||||
def test_change_avatar_source(self) -> None:
|
def test_change_avatar_source(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue