From e89229a2ca5400e94aa5a4e8c239c556b6e08d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 6 Jul 2020 18:39:27 +0300 Subject: [PATCH] In admin, visualize account's number of checks --- hc/accounts/admin.py | 6 +++++- static/css/admin/profiles.css | 12 ++++++++++++ templates/admin/profile_list_projects.html | 9 --------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/hc/accounts/admin.py b/hc/accounts/admin.py index 04cca00c..3e5fe6e0 100644 --- a/hc/accounts/admin.py +++ b/hc/accounts/admin.py @@ -72,6 +72,7 @@ class NumChecksFilter(admin.SimpleListFilter): def lookups(self, request, model_admin): return ( + ("10", "more than 10"), ("20", "more than 20"), ("50", "more than 50"), ("100", "more than 100"), @@ -129,7 +130,10 @@ class ProfileAdmin(admin.ModelAdmin): def email(self, obj): s = escape(obj.user.email) if obj.plan: - return "%s" % (obj.plan, s) + s = "%s" % (obj.plan, s) + + v = min(30, obj.num_checks) * 8 + s += """
""" % v return s diff --git a/static/css/admin/profiles.css b/static/css/admin/profiles.css index 47b22758..9b8a91f1 100644 --- a/static/css/admin/profiles.css +++ b/static/css/admin/profiles.css @@ -10,4 +10,16 @@ .field-email span { border-bottom: 2px solid #FFEB3B; +} + +.nchecks { + margin-top: 4px; + width: 240px; + height: 7px; + background-image: url(data:image/gif;base64,R0lGODlh8AABAKECAN3d3e7u7v///////yH5BAEKAAMALAAAAADwAAEAAAImhA+Cp5v+XFsTVQav0ZHmL4FeSFLBiQZCiq6s+sKvy9Kp3cb4KRQAOw==); +} + +.nchecks div { + background-image: url(data:image/gif;base64,R0lGODlhCAABAKEBAHmuyP///////////yH5BAEKAAIALAAAAAAIAAEAAAIDhA9RADs=); + height: 7px; } \ No newline at end of file diff --git a/templates/admin/profile_list_projects.html b/templates/admin/profile_list_projects.html index c8e624c5..fa701af9 100644 --- a/templates/admin/profile_list_projects.html +++ b/templates/admin/profile_list_projects.html @@ -2,15 +2,6 @@ {% for project in profile.user.project_set.all %}
  • {{ project }} - {% if profile.num_checks > 1 %} - {% with project.num_checks as n %} - {% if n > 1 %} - ({{ n }}) - {% else %} - ({{ n }}) - {% endif %} - {% endwith %} - {% endif %}
  • {% endfor %} \ No newline at end of file