From 5d621fb4b75c0c3f0a063682b101dc4cf27c77bb Mon Sep 17 00:00:00 2001 From: Artem Martynovich Date: Thu, 16 Jan 2020 19:37:22 +0600 Subject: [PATCH 1/3] 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: From ad74b30fdeda8f838a505896ef34a5a1b581bc38 Mon Sep 17 00:00:00 2001 From: Artem Martynovich Date: Fri, 17 Jan 2020 14:33:49 +0600 Subject: [PATCH 2/3] Hook up progress bars to real values. Move max weekly RA to settings, use it in template; limit actions_resolved_since_monday to this value. --- backend/backend/settings/base.py | 2 ++ .../device_registry/templates/admin_base.html | 18 +++++------------- backend/device_registry/templatetags/misc.py | 7 +++++++ backend/profile_page/models.py | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/backend/backend/settings/base.py b/backend/backend/settings/base.py index d6aa7381c..f9714101b 100644 --- a/backend/backend/settings/base.py +++ b/backend/backend/settings/base.py @@ -287,3 +287,5 @@ def check_ip_range(ipr): GITHUB_APP_CLIENT_ID = os.getenv('GITHUB_APP_CLIENT_ID') # Github app Client ID GITHUB_APP_CLIENT_SECRET = os.getenv('GITHUB_APP_CLIENT_SECRET') # Github App Client Secret GITHUB_APP_REDIRECT_URL = os.getenv('GITHUB_APP_REDIRECT_URL') # Github App Redirect URL + +MAX_WEEKLY_RA = 5 diff --git a/backend/device_registry/templates/admin_base.html b/backend/device_registry/templates/admin_base.html index 013a5eac8..1861045d7 100644 --- a/backend/device_registry/templates/admin_base.html +++ b/backend/device_registry/templates/admin_base.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load static %} {% load highlight_selector %} +{% load misc %} {% block css %} {% endblock %} @@ -101,14 +102,14 @@

Status Overview