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.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):
|
def involvement(self, user):
|
||||||
return Check.objects.filter(user=user).count()
|
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)
|
||||||
|
@ -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):
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -24,3 +24,8 @@
|
|||||||
padding-top: 2px;
|
padding-top: 2px;
|
||||||
font-size: 9px;
|
font-size: 9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel-checks-table .unnamed {
|
||||||
|
color: #999;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
@ -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 {
|
.edit-checks {
|
||||||
padding-left: 40px;
|
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>
|
||||||
<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>
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
class="toggle" />
|
class="toggle" />
|
||||||
</th>
|
</th>
|
||||||
<th class="check-all-cell">
|
<th class="check-all-cell" colspan="2">
|
||||||
Check / Uncheck All
|
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 %}
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user