mirror of https://github.com/zulip/zulip.git
audit-logs: Use AuditLogEventType enum name for string method.
Reorders audit log string methods to have the following pattern: "event_type event_time (id): modified_object". And the event type is the name for the AuditLogEventType enum.
This commit is contained in:
parent
00ecd4c8f0
commit
d610e09397
|
@ -262,10 +262,13 @@ class RealmAuditLog(AbstractRealmAuditLog):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
event_type_name = AuditLogEventType(self.event_type).name
|
||||||
if self.modified_user is not None:
|
if self.modified_user is not None:
|
||||||
return f"{self.modified_user!r} {self.event_type} {self.event_time} {self.id}"
|
return f"{event_type_name} {self.event_time} (id={self.id}): {self.modified_user!r}"
|
||||||
if self.modified_stream is not None:
|
if self.modified_stream is not None:
|
||||||
return f"{self.modified_stream!r} {self.event_type} {self.event_time} {self.id}"
|
return f"{event_type_name} {self.event_time} (id={self.id}): {self.modified_stream!r}"
|
||||||
if self.modified_user_group is not None:
|
if self.modified_user_group is not None:
|
||||||
return f"{self.modified_user_group!r} {self.event_type} {self.event_time} {self.id}"
|
return (
|
||||||
return f"{self.realm!r} {self.event_type} {self.event_time} {self.id}"
|
f"{event_type_name} {self.event_time} (id={self.id}): {self.modified_user_group!r}"
|
||||||
|
)
|
||||||
|
return f"{event_type_name} {self.event_time} (id={self.id}): {self.realm!r}"
|
||||||
|
|
|
@ -292,7 +292,7 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||||
)
|
)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
repr(audit_entry).startswith(
|
repr(audit_entry).startswith(
|
||||||
f"<RealmAuditLog: <UserProfile: {user.email} {user.realm!r}> {AuditLogEventType.USER_EMAIL_CHANGED} "
|
f"<RealmAuditLog: {AuditLogEventType.USER_EMAIL_CHANGED.name} "
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ from analytics.models import BaseCount
|
||||||
from zerver.lib.rate_limiter import RateLimitedObject
|
from zerver.lib.rate_limiter import RateLimitedObject
|
||||||
from zerver.lib.rate_limiter import rules as rate_limiter_rules
|
from zerver.lib.rate_limiter import rules as rate_limiter_rules
|
||||||
from zerver.models import AbstractPushDeviceToken, AbstractRealmAuditLog, Realm, UserProfile
|
from zerver.models import AbstractPushDeviceToken, AbstractRealmAuditLog, Realm, UserProfile
|
||||||
|
from zerver.models.realm_audit_logs import AuditLogEventType
|
||||||
|
|
||||||
|
|
||||||
def get_remote_server_by_uuid(uuid: str) -> "RemoteZulipServer":
|
def get_remote_server_by_uuid(uuid: str) -> "RemoteZulipServer":
|
||||||
|
@ -292,7 +293,8 @@ class RemoteZulipServerAuditLog(AbstractRealmAuditLog):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.server!r} {self.event_type} {self.event_time} {self.id}"
|
event_type_name = AuditLogEventType(self.event_type).name
|
||||||
|
return f"{event_type_name} {self.event_time} (id={self.id}): {self.server!r}"
|
||||||
|
|
||||||
|
|
||||||
class RemoteRealmAuditLog(AbstractRealmAuditLog):
|
class RemoteRealmAuditLog(AbstractRealmAuditLog):
|
||||||
|
@ -319,7 +321,8 @@ class RemoteRealmAuditLog(AbstractRealmAuditLog):
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.server!r} {self.event_type} {self.event_time} {self.id}"
|
event_type_name = AuditLogEventType(self.event_type).name
|
||||||
|
return f"{event_type_name} {self.event_time} (id={self.id}): {self.server!r}"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
constraints = [
|
constraints = [
|
||||||
|
|
Loading…
Reference in New Issue