forked from GithubBackups/healthchecks
Admin tweaks, style tweaks. Channels page included in navigation.
This commit is contained in:
parent
2f56da9f57
commit
ab58e76ca2
@ -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 += "<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.register(User, HcUserAdmin)
|
||||
|
@ -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 <i>(unverified)</i>"
|
||||
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):
|
||||
|
@ -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
|
||||
|
||||
|
@ -23,4 +23,9 @@
|
||||
padding-left: 4px;
|
||||
padding-top: 2px;
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.channel-checks-table .unnamed {
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -45,6 +45,18 @@
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<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 %}>
|
||||
<a href="{% url 'hc-pricing' %}">Pricing</a>
|
||||
</li>
|
||||
|
@ -17,8 +17,8 @@
|
||||
type="checkbox"
|
||||
class="toggle" />
|
||||
</th>
|
||||
<th class="check-all-cell">
|
||||
Check / Uncheck All
|
||||
<th class="check-all-cell" colspan="2">
|
||||
Select / Unselect All
|
||||
</th>
|
||||
</tr>
|
||||
{% for check in checks %}
|
||||
@ -33,7 +33,14 @@
|
||||
|
||||
</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>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -16,7 +16,7 @@
|
||||
<th></th>
|
||||
</tr>
|
||||
{% for ch in channels %}
|
||||
<tr>
|
||||
<tr class="channel-row">
|
||||
<td>
|
||||
{% if ch.kind == "email" %} Email {% endif %}
|
||||
{% if ch.kind == "webhook" %} Webhook {% endif %}
|
||||
@ -41,6 +41,9 @@
|
||||
{{ ch.checks.count }} of {{ num_checks }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user