From 5d621fb4b75c0c3f0a063682b101dc4cf27c77bb Mon Sep 17 00:00:00 2001 From: Artem Martynovich Date: Thu, 16 Jan 2020 19:37:22 +0600 Subject: [PATCH] Data for Current Trust Score and Action Solved elements on every page. --- backend/device_registry/templates/admin_base.html | 10 +++++----- backend/profile_page/models.py | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/device_registry/templates/admin_base.html b/backend/device_registry/templates/admin_base.html index 6478e0b83..013a5eac8 100644 --- a/backend/device_registry/templates/admin_base.html +++ b/backend/device_registry/templates/admin_base.html @@ -101,14 +101,14 @@

Status Overview

- + {% endblock %} {% block scripts %} @@ -165,7 +165,7 @@

Status Overview

#trust-graph-var { width: 75%; } - + {% endblock %} diff --git a/backend/profile_page/models.py b/backend/profile_page/models.py index d43912670..e4c3e9808 100644 --- a/backend/profile_page/models.py +++ b/backend/profile_page/models.py @@ -9,6 +9,7 @@ from django.dispatch import receiver from django.utils import timezone +from dateutil.relativedelta import relativedelta, MO from mixpanel import Mixpanel, MixpanelException from phonenumber_field.modelfields import PhoneNumberField @@ -53,6 +54,12 @@ def actions_count(self): Q(device__owner=self.user) & RecommendedAction.get_affected_query()) \ .values('action_id').distinct().count() + @property + def actions_resolved_since_monday(self): + monday = (timezone.now() - relativedelta(weekday=MO(-1))).date() + return RecommendedAction.objects.filter(device__owner=self.user, resolved_at__gte=monday)\ + .values('action_id').distinct().count() + @property def github_repos(self): try: