Add templates to display new audit events
This commit is contained in:
parent
a1eb7ec935
commit
a65f758894
@ -53,7 +53,10 @@ class ApplicationRole(
|
||||
|
||||
@property
|
||||
def user_name(self):
|
||||
if self.user:
|
||||
return self.user.full_name
|
||||
else:
|
||||
return None
|
||||
|
||||
def __repr__(self):
|
||||
return "<ApplicationRole(application='{}', user_id='{}', id='{}', permissions={})>".format(
|
||||
@ -79,6 +82,16 @@ class ApplicationRole(
|
||||
def portfolio_id(self):
|
||||
return self.application.portfolio_id
|
||||
|
||||
@property
|
||||
def event_details(self):
|
||||
return {
|
||||
"updated_user_name": self.user_name,
|
||||
"updated_user_id": str(self.user_id),
|
||||
"application": self.application.name,
|
||||
"portfolio": self.application.portfolio.name,
|
||||
}
|
||||
|
||||
|
||||
Index(
|
||||
"application_role_user_application",
|
||||
ApplicationRole.user_id,
|
||||
|
@ -105,3 +105,23 @@ class InvitesMixin(object):
|
||||
@property
|
||||
def user_dod_id(self):
|
||||
return self.user.dod_id if self.user is not None else None
|
||||
|
||||
@property
|
||||
def event_details(self):
|
||||
"""Overrides the same property in AuditableMixin.
|
||||
Provides the event details for an invite that are required for the audit log
|
||||
"""
|
||||
return {"email": self.email, "dod_id": self.user_dod_id}
|
||||
|
||||
@property
|
||||
def history(self):
|
||||
"""Overrides the same property in AuditableMixin
|
||||
Determines whether or not invite status has been updated
|
||||
"""
|
||||
changes = self.get_changes()
|
||||
change_set = {}
|
||||
|
||||
if "status" in changes:
|
||||
change_set["status"] = [s.name for s in changes["status"]]
|
||||
|
||||
return change_set
|
||||
|
@ -6,7 +6,7 @@ from atst.models import Base
|
||||
from atst.models.mixins import TimestampsMixin, AuditableMixin, InvitesMixin
|
||||
|
||||
|
||||
class PortfolioInvitation(Base, TimestampsMixin, AuditableMixin, InvitesMixin):
|
||||
class PortfolioInvitation(Base, TimestampsMixin, InvitesMixin, AuditableMixin):
|
||||
__tablename__ = "portfolio_invitations"
|
||||
|
||||
portfolio_role_id = Column(
|
||||
@ -25,17 +25,3 @@ class PortfolioInvitation(Base, TimestampsMixin, AuditableMixin, InvitesMixin):
|
||||
@property
|
||||
def portfolio_id(self):
|
||||
return self.role.portfolio_id
|
||||
|
||||
@property
|
||||
def event_details(self):
|
||||
return {"email": self.email, "dod_id": self.user_dod_id}
|
||||
|
||||
@property
|
||||
def history(self):
|
||||
changes = self.get_changes()
|
||||
change_set = {}
|
||||
|
||||
if "status" in changes:
|
||||
change_set["status"] = [s.name for s in changes["status"]]
|
||||
|
||||
return change_set
|
||||
|
16
templates/audit_log/events/application_invitation.html
Normal file
16
templates/audit_log/events/application_invitation.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends 'audit_log/events/_base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% set accepted = event.changed_state.status and event.changed_state.status.1 == "ACCEPTED" %}
|
||||
{% if accepted %}
|
||||
accepted by {{ event.event_details.email }} (DOD <code>{{ event.event_details.dod_id }}</code>)
|
||||
<br>
|
||||
{% endif %}
|
||||
{% if event.action == "create" %}
|
||||
invited {{ event.event_details.email }} (DOD <code>{{ event.event_details.dod_id }}</code>)
|
||||
<br>
|
||||
{% endif %}
|
||||
in Application <code>{{ event.application_id }}</code> ({{ event.application.name }})
|
||||
<br>
|
||||
in Portfolio <code>{{ event.portfolio_id }}</code> ({{ event.portfolio.name }})
|
||||
{% endblock %}
|
9
templates/audit_log/events/application_role.html
Normal file
9
templates/audit_log/events/application_role.html
Normal file
@ -0,0 +1,9 @@
|
||||
{% extends 'audit_log/events/_base.html' %}
|
||||
|
||||
{% block content %}
|
||||
for User <code>{{ event.event_details.updated_user_id }}</code> ({{ event.event_details.updated_user_name }})
|
||||
<br>
|
||||
in Application <code>{{ event.application_id}}</code> ({{ event.event_details.application }})
|
||||
<br>
|
||||
in Portfolio <code>{{ event.portfolio_id }}</code> ({{ event.event_details.portfolio }})
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user