mirror of https://github.com/zulip/zulip.git
models: Add USER_API_KEY_CHANGED event type constant to RealmAuditLog.
This commit is contained in:
parent
0d69fc482b
commit
d5b6f032d2
|
@ -2881,7 +2881,7 @@ def do_regenerate_api_key(user_profile: UserProfile, acting_user: UserProfile) -
|
||||||
user_profile.save(update_fields=["api_key"])
|
user_profile.save(update_fields=["api_key"])
|
||||||
event_time = timezone_now()
|
event_time = timezone_now()
|
||||||
RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=acting_user,
|
RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=acting_user,
|
||||||
modified_user=user_profile, event_type='user_api_key_changed',
|
modified_user=user_profile, event_type=RealmAuditLog.USER_API_KEY_CHANGED,
|
||||||
event_time=event_time)
|
event_time=event_time)
|
||||||
|
|
||||||
if user_profile.is_bot:
|
if user_profile.is_bot:
|
||||||
|
|
|
@ -1971,6 +1971,7 @@ class RealmAuditLog(models.Model):
|
||||||
USER_FULL_NAME_CHANGED = 'user_full_name_changed'
|
USER_FULL_NAME_CHANGED = 'user_full_name_changed'
|
||||||
USER_EMAIL_CHANGED = 'user_email_changed'
|
USER_EMAIL_CHANGED = 'user_email_changed'
|
||||||
USER_TOS_VERSION_CHANGED = 'user_tos_version_changed'
|
USER_TOS_VERSION_CHANGED = 'user_tos_version_changed'
|
||||||
|
USER_API_KEY_CHANGED = 'user_api_key_changed'
|
||||||
|
|
||||||
event_type = models.CharField(max_length=40) # type: str
|
event_type = models.CharField(max_length=40) # type: str
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||||
now = timezone_now()
|
now = timezone_now()
|
||||||
user = self.example_user('hamlet')
|
user = self.example_user('hamlet')
|
||||||
do_regenerate_api_key(user, user)
|
do_regenerate_api_key(user, user)
|
||||||
self.assertEqual(RealmAuditLog.objects.filter(event_type='user_api_key_changed',
|
self.assertEqual(RealmAuditLog.objects.filter(event_type=RealmAuditLog.USER_API_KEY_CHANGED,
|
||||||
event_time__gte=now).count(), 1)
|
event_time__gte=now).count(), 1)
|
||||||
self.assertTrue(user.api_key)
|
self.assertTrue(user.api_key)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue