From 7a5d733b20de6422a65981002f8a8f654498dd50 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Tue, 25 Sep 2018 16:02:52 -0400 Subject: [PATCH 1/4] log activity description prop --- atst/models/audit_event.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/atst/models/audit_event.py b/atst/models/audit_event.py index e402e631..549a618f 100644 --- a/atst/models/audit_event.py +++ b/atst/models/audit_event.py @@ -42,6 +42,22 @@ class AuditEvent(Base, TimestampsMixin): return " ".join([user_str, action_str, display_name_str, scope_str]) + + @property + def activity_description(self): + action_str = "{} on {} {}".format( + self.action, self.resource_type, self.resource_id + ) + display_name_str = "({})".format(self.display_name) if self.display_name else "" + scope_str = "" + if self.request_id and self.resource_type != "request": + scope_str = "for request {}".format(self.request_id) + elif self.workspace_id and self.resource_type != "workspace": + scope_str = "in workspace {}".format(self.workspace_id) + + return " ".join([action_str, display_name_str, scope_str]) + + def save(self, connection): attrs = inspect(self).dict From 155ee1c21dfad6ae1da8c17691a0b3be70a90333 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Tue, 25 Sep 2018 16:03:00 -0400 Subject: [PATCH 2/4] audit log style --- styles/atat.scss | 1 + styles/components/_audit_log.scss | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 styles/components/_audit_log.scss diff --git a/styles/atat.scss b/styles/atat.scss index ebaaa214..a908d116 100644 --- a/styles/atat.scss +++ b/styles/atat.scss @@ -35,6 +35,7 @@ @import 'components/forms'; @import 'components/selector'; @import 'components/budget_chart'; +@import 'components/audit_log'; @import 'sections/login'; @import 'sections/request_approval'; diff --git a/styles/components/_audit_log.scss b/styles/components/_audit_log.scss new file mode 100644 index 00000000..212ebb83 --- /dev/null +++ b/styles/components/_audit_log.scss @@ -0,0 +1,22 @@ +.audit-log__item { + display: flex; + flex-direction: row; + align-items: flex-start; + justify-content: flex-start; + + .audit-log__item__timestamp { + @include small-label; + width: 6rem; + flex-shrink: 0; + margin-right: $gap * 2; + + @include media($medium-screen) { + width: 12rem; + } + } + + .audit-log__item__name { + margin-top: 0; + margin-bottom: $gap; + } +} From d87f2b17edb403860a4ae151395505624660afbf Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Tue, 25 Sep 2018 16:03:08 -0400 Subject: [PATCH 3/4] audit log markup --- templates/audit_log.html | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/templates/audit_log.html b/templates/audit_log.html index 68b54f80..2ae23517 100644 --- a/templates/audit_log.html +++ b/templates/audit_log.html @@ -3,20 +3,31 @@ {% block content %} -
-
-
-

Acitivity History

-
+
+
+

Activity History

+
-
    - {% for event in audit_events %} -
  • {{ event }}
  • - {% endfor %} -
+
    + {% for event in audit_events %} +
  • +
    +
    + +
    -
+
+

+ {{ event.user.full_name if event.user else "ATAT System" }} +

+ {{ event.activity_description }} +
+ + + {% endfor %} + + +
-
{% endblock %} From 9ec8caa9b61ba6c70bc80ddabd5aa20c14418a45 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Wed, 26 Sep 2018 08:26:05 -0400 Subject: [PATCH 4/4] format --- atst/models/audit_event.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/atst/models/audit_event.py b/atst/models/audit_event.py index 549a618f..ea15d5f2 100644 --- a/atst/models/audit_event.py +++ b/atst/models/audit_event.py @@ -42,7 +42,6 @@ class AuditEvent(Base, TimestampsMixin): return " ".join([user_str, action_str, display_name_str, scope_str]) - @property def activity_description(self): action_str = "{} on {} {}".format( @@ -57,7 +56,6 @@ class AuditEvent(Base, TimestampsMixin): return " ".join([action_str, display_name_str, scope_str]) - def save(self, connection): attrs = inspect(self).dict