Browse Source

Admin tweaks, style tweaks. Channels page included in navigation.

pull/7/head
Pēteris Caune 9 years ago
parent
commit
ab58e76ca2
8 changed files with 88 additions and 11 deletions
  1. +25
    -4
      hc/accounts/admin.py
  2. +3
    -1
      hc/api/admin.py
  3. +2
    -0
      hc/front/views.py
  4. +5
    -0
      static/css/channel_checks.css
  5. +27
    -2
      static/css/channels.css
  6. +12
    -0
      templates/base.html
  7. +10
    -3
      templates/front/channel_checks.html
  8. +4
    -1
      templates/front/channels.html

+ 25
- 4
hc/accounts/admin.py View File

@ -4,17 +4,38 @@ from django.contrib import admin
from django.contrib.auth.admin import UserAdmin from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User from django.contrib.auth.models import User
from hc.api.models import Check
from hc.api.models import Channel, Check
class HcUserAdmin(UserAdmin): class HcUserAdmin(UserAdmin):
list_display = ('id', 'username', 'email', 'date_joined', 'num_checks',
list_display = ('id', 'username', 'email', 'date_joined', 'involvement',
'is_staff') 'is_staff')
ordering = ["-id"] 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 += "<strong>%d checks</strong>, " % num_checks
if num_channels == 0:
result += "0 channels"
elif num_channels == 1:
result += "1 channel, "
else:
result += "<strong>%d channels</strong>, " % num_channels
return result
involvement.allow_tags = True
admin.site.unregister(User) admin.site.unregister(User)
admin.site.register(User, HcUserAdmin) admin.site.register(User, HcUserAdmin)

+ 3
- 1
hc/api/admin.py View File

@ -71,10 +71,12 @@ class ChannelsAdmin(admin.ModelAdmin):
elif obj.kind == "email" and obj.email_verified: elif obj.kind == "email" and obj.email_verified:
return "Email" return "Email"
elif obj.kind == "email" and not obj.email_verified: elif obj.kind == "email" and not obj.email_verified:
return "Email (unverified)"
return "Email <i>(unverified)</i>"
else: else:
raise NotImplementedError("Bad channel kind: %s" % obj.kind) raise NotImplementedError("Bad channel kind: %s" % obj.kind)
formatted_kind.short_description = "Kind"
formatted_kind.allow_tags = True
@admin.register(Notification) @admin.register(Notification)
class NotificationsAdmin(admin.ModelAdmin): class NotificationsAdmin(admin.ModelAdmin):


+ 2
- 0
hc/front/views.py View File

@ -34,6 +34,7 @@ def _my_checks(request):
checks = Check.objects.filter(user=request.user).order_by("created") checks = Check.objects.filter(user=request.user).order_by("created")
ctx = { ctx = {
"page": "checks",
"checks": checks, "checks": checks,
"now": timezone.now() "now": timezone.now()
} }
@ -198,6 +199,7 @@ def channels(request):
num_checks = Check.objects.filter(user=request.user).count() num_checks = Check.objects.filter(user=request.user).count()
ctx = { ctx = {
"page": "channels",
"channels": channels, "channels": channels,
"num_checks": num_checks "num_checks": num_checks


+ 5
- 0
static/css/channel_checks.css View File

@ -23,4 +23,9 @@
padding-left: 4px; padding-left: 4px;
padding-top: 2px; padding-top: 2px;
font-size: 9px; font-size: 9px;
}
.channel-checks-table .unnamed {
color: #999;
font-style: italic;
} }

+ 27
- 2
static/css/channels.css View File

@ -2,6 +2,16 @@
margin-top: 36px; 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 { table.channels-table > tbody > tr > th {
border-top: 0; border-top: 0;
} }
@ -38,7 +48,22 @@ table.channels-table > tbody > tr > th {
display: none; 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;
}

+ 12
- 0
templates/base.html View File

@ -45,6 +45,18 @@
</div> </div>
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{% if request.user.is_authenticated %}
<li {% if page == 'checks' %} class="active" {% endif %}>
<a href="{% url 'hc-index' %}">Checks</a>
</li>
<li {% if page == 'channels' %} class="active" {% endif %}>
<a href="{% url 'hc-channels' %}">Channels</a>
</li>
{% endif %}
<li {% if page == 'pricing' %} class="active" {% endif %}> <li {% if page == 'pricing' %} class="active" {% endif %}>
<a href="{% url 'hc-pricing' %}">Pricing</a> <a href="{% url 'hc-pricing' %}">Pricing</a>
</li> </li>


+ 10
- 3
templates/front/channel_checks.html View File

@ -17,8 +17,8 @@
type="checkbox" type="checkbox"
class="toggle" /> class="toggle" />
</th> </th>
<th class="check-all-cell">
Check / Uncheck All
<th class="check-all-cell" colspan="2">
Select / Unselect All
</th> </th>
</tr> </tr>
{% for check in checks %} {% for check in checks %}
@ -33,7 +33,14 @@
</td> </td>
<td> <td>
{{ check.name|default:check.code }}
{% if check.name %}
{{ check.name }}
{% else %}
<span class="unnamed">unnamed</span>
{% endif %}
</td>
<td>
<code>{{ check.code }}</code>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}


+ 4
- 1
templates/front/channels.html View File

@ -16,7 +16,7 @@
<th></th> <th></th>
</tr> </tr>
{% for ch in channels %} {% for ch in channels %}
<tr>
<tr class="channel-row">
<td> <td>
{% if ch.kind == "email" %} Email {% endif %} {% if ch.kind == "email" %} Email {% endif %}
{% if ch.kind == "webhook" %} Webhook {% endif %} {% if ch.kind == "webhook" %} Webhook {% endif %}
@ -41,6 +41,9 @@
{{ ch.checks.count }} of {{ num_checks }} {{ ch.checks.count }} of {{ num_checks }}
</a> </a>
</td> </td>
<td>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
<tr> <tr>


Loading…
Cancel
Save