Rename resource_name to resource_type
This commit is contained in:
@@ -17,13 +17,13 @@ class AuditEvent(Base, TimestampsMixin):
|
||||
workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id"), index=True)
|
||||
workspace = relationship("Workspace", backref="audit_events")
|
||||
|
||||
resource_name = Column(String(), nullable=False)
|
||||
resource_type = Column(String(), nullable=False)
|
||||
resource_id = Column(UUID(as_uuid=True), index=True, nullable=False)
|
||||
action = Column(String(), nullable=False)
|
||||
|
||||
def __str__(self):
|
||||
full_action = "{} on {} {}".format(
|
||||
self.action, self.resource_name, self.resource_id
|
||||
self.action, self.resource_type, self.resource_id
|
||||
)
|
||||
|
||||
if self.user and self.workspace:
|
||||
|
@@ -26,12 +26,12 @@ class AuditableMixin(object):
|
||||
def create_audit_event(connection, resource, action):
|
||||
user_id = getattr_path(g, "current_user.id")
|
||||
workspace_id = resource.auditable_workspace_id()
|
||||
resource_name = resource.auditable_resource_name()
|
||||
resource_type = resource.auditable_resource_type()
|
||||
|
||||
audit_event = AuditEvent(
|
||||
user_id=user_id,
|
||||
workspace_id=workspace_id,
|
||||
resource_name=resource_name,
|
||||
resource_type=resource_type,
|
||||
resource_id=resource.id,
|
||||
action=action,
|
||||
)
|
||||
@@ -58,7 +58,7 @@ class AuditableMixin(object):
|
||||
def audit_update(mapper, connection, target):
|
||||
target.create_audit_event(connection, target, ACTION_UPDATE)
|
||||
|
||||
def auditable_resource_name(self):
|
||||
def auditable_resource_type(self):
|
||||
return camel_to_snake(type(self).__name__)
|
||||
|
||||
def auditable_workspace_id(self):
|
||||
|
Reference in New Issue
Block a user