From edb8b88d060e50ae59b69557e1386f8751fc192b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 2 Jun 2017 19:04:48 +0300 Subject: [PATCH] Profile admin improvements --- hc/accounts/admin.py | 18 +++++++++++------- static/css/admin/profiles.css | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/hc/accounts/admin.py b/hc/accounts/admin.py index ec3faf55..3f1fc81a 100644 --- a/hc/accounts/admin.py +++ b/hc/accounts/admin.py @@ -56,10 +56,14 @@ class ProfileAdmin(admin.ModelAdmin): }) def checks(self, obj): - current = Check.objects.filter(user=obj.user).count() - text = "%d of %d" % (current, obj.check_limit) - url = reverse("hc-switch-team", args=[obj.user.username]) - return "%s" % (url, text) + num_checks = Check.objects.filter(user=obj.user).count() + pct = 100 * num_checks / max(obj.check_limit, 1) + pct = min(100, int(pct)) + + return """ + +   %d of %d + """ % (pct, num_checks, obj.check_limit) def email(self, obj): return obj.user.email @@ -70,14 +74,14 @@ class ProfileAdmin(admin.ModelAdmin): class HcUserAdmin(UserAdmin): actions = ["send_report"] - list_display = ('id', 'email', 'date_joined', 'involvement', + list_display = ('id', 'email', 'date_joined', 'engagement', 'is_staff', 'checks') list_filter = ("last_login", "date_joined", "is_staff", "is_active") ordering = ["-id"] - def involvement(self, user): + def engagement(self, user): result = "" num_checks = Check.objects.filter(user=user).count() num_channels = Channel.objects.filter(user=user).count() @@ -98,7 +102,7 @@ class HcUserAdmin(UserAdmin): return result - involvement.allow_tags = True + engagement.allow_tags = True def checks(self, user): url = reverse("hc-switch-team", args=[user.username]) diff --git a/static/css/admin/profiles.css b/static/css/admin/profiles.css index cc571bf5..3588349e 100644 --- a/static/css/admin/profiles.css +++ b/static/css/admin/profiles.css @@ -7,4 +7,24 @@ .field-users ul li { list-style-type: none; -} \ No newline at end of file +} + +.field-checks { + color: #888; +} + +.bar { + display: inline-block; + width: 100px; + height: 10px; + border-radius: 5px; + overflow: hidden; + background: #ddd; +} + +.bar span { + display: block; + height: 10px; + background: #79aec8; +} +