From ab58e76ca229b084feb6c7fe1f1e4597454ba306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 14 Aug 2015 11:58:27 +0300 Subject: [PATCH] Admin tweaks, style tweaks. Channels page included in navigation. --- hc/accounts/admin.py | 29 +++++++++++++++++++++++++---- hc/api/admin.py | 4 +++- hc/front/views.py | 2 ++ static/css/channel_checks.css | 5 +++++ static/css/channels.css | 29 +++++++++++++++++++++++++++-- templates/base.html | 12 ++++++++++++ templates/front/channel_checks.html | 13 ++++++++++--- templates/front/channels.html | 5 ++++- 8 files changed, 88 insertions(+), 11 deletions(-) diff --git a/hc/accounts/admin.py b/hc/accounts/admin.py index 58fe51eb..17633675 100644 --- a/hc/accounts/admin.py +++ b/hc/accounts/admin.py @@ -4,17 +4,38 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User -from hc.api.models import Check +from hc.api.models import Channel, Check class HcUserAdmin(UserAdmin): - list_display = ('id', 'username', 'email', 'date_joined', 'num_checks', + list_display = ('id', 'username', 'email', 'date_joined', 'involvement', 'is_staff') ordering = ["-id"] - def num_checks(self, user): - return Check.objects.filter(user=user).count() + def involvement(self, user): + result = "" + num_checks = Check.objects.filter(user=user).count() + num_channels = Channel.objects.filter(user=user).count() + + if num_checks == 0: + result += "0 checks, " + elif num_checks == 1: + result += "1 check, " + else: + result += "%d checks, " % num_checks + + if num_channels == 0: + result += "0 channels" + elif num_channels == 1: + result += "1 channel, " + else: + result += "%d channels, " % num_channels + + return result + + involvement.allow_tags = True + admin.site.unregister(User) admin.site.register(User, HcUserAdmin) diff --git a/hc/api/admin.py b/hc/api/admin.py index b4fb767a..f3b69a68 100644 --- a/hc/api/admin.py +++ b/hc/api/admin.py @@ -71,10 +71,12 @@ class ChannelsAdmin(admin.ModelAdmin): elif obj.kind == "email" and obj.email_verified: return "Email" elif obj.kind == "email" and not obj.email_verified: - return "Email (unverified)" + return "Email (unverified)" else: raise NotImplementedError("Bad channel kind: %s" % obj.kind) + formatted_kind.short_description = "Kind" + formatted_kind.allow_tags = True @admin.register(Notification) class NotificationsAdmin(admin.ModelAdmin): diff --git a/hc/front/views.py b/hc/front/views.py index 0eff3545..a4c9f860 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -34,6 +34,7 @@ def _my_checks(request): checks = Check.objects.filter(user=request.user).order_by("created") ctx = { + "page": "checks", "checks": checks, "now": timezone.now() } @@ -198,6 +199,7 @@ def channels(request): num_checks = Check.objects.filter(user=request.user).count() ctx = { + "page": "channels", "channels": channels, "num_checks": num_checks diff --git a/static/css/channel_checks.css b/static/css/channel_checks.css index ef595f2b..38959da2 100644 --- a/static/css/channel_checks.css +++ b/static/css/channel_checks.css @@ -23,4 +23,9 @@ padding-left: 4px; padding-top: 2px; font-size: 9px; +} + +.channel-checks-table .unnamed { + color: #999; + font-style: italic; } \ No newline at end of file diff --git a/static/css/channels.css b/static/css/channels.css index 7267e2df..79011c4b 100644 --- a/static/css/channels.css +++ b/static/css/channels.css @@ -2,6 +2,16 @@ margin-top: 36px; } +.channels-table .channel-row > td { + line-height: 40px; +} + +.channels-table .channel-row:hover > td { + background: #f5f5f5; +} + + + table.channels-table > tbody > tr > th { border-top: 0; } @@ -38,7 +48,22 @@ table.channels-table > tbody > tr > th { display: none; } -.channels-table .channels-num-checks { - padding-left: 40px; +.edit-checks { + display: inline-block; + width: 120px; + padding: 6px; + text-align: center; + line-height: 28px; + border: 1px solid #FFF; + color: #333; + } +.edit-checks:hover { + text-decoration: none; + color: #000; +} + +.channel-row:hover .edit-checks { + border: 1px dotted #AAA; +} diff --git a/templates/base.html b/templates/base.html index 0a05dd0f..a73719f9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -45,6 +45,18 @@