Browse Source

Channel icons in Admin > Channels

pull/366/head
Pēteris Caune 5 years ago
parent
commit
825110a354
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 10 additions and 11 deletions
  1. +5
    -10
      hc/api/admin.py
  2. +5
    -1
      templates/admin/base_site.html

+ 5
- 10
hc/api/admin.py View File

@ -42,7 +42,7 @@ class ChecksAdmin(admin.ModelAdmin):
url = reverse("hc-checks", args=[obj.project.code]) url = reverse("hc-checks", args=[obj.project.code])
name = escape(obj.project_name or "Default") name = escape(obj.project_name or "Default")
email = escape(obj.email) email = escape(obj.email)
return f'<a href="{url}"">{name}</a> &bull; {email}'
return f'{email} &rsaquo; <a href="{url}"">{name}</a>'
@mark_safe @mark_safe
def name_tags(self, obj): def name_tags(self, obj):
@ -177,9 +177,9 @@ class ChannelsAdmin(admin.ModelAdmin):
search_fields = ["value", "project__owner__email"] search_fields = ["value", "project__owner__email"]
list_display = ( list_display = (
"id", "id",
"kind_",
"name", "name",
"project_", "project_",
"formatted_kind",
"value", "value",
"num_notifications", "num_notifications",
) )
@ -191,7 +191,7 @@ class ChannelsAdmin(admin.ModelAdmin):
url = reverse("hc-checks", args=[obj.project.code]) url = reverse("hc-checks", args=[obj.project.code])
name = escape(obj.project_name or "Default") name = escape(obj.project_name or "Default")
email = escape(obj.email) email = escape(obj.email)
return f"<a href='{url}'>{name}</a> &bull; {email}"
return f"{email} &rsaquo; <a href='{url}'>{name}</a>"
def get_queryset(self, request): def get_queryset(self, request):
qs = super().get_queryset(request) qs = super().get_queryset(request)
@ -201,13 +201,8 @@ class ChannelsAdmin(admin.ModelAdmin):
return qs return qs
@mark_safe @mark_safe
def formatted_kind(self, obj):
if obj.kind == "email" and not obj.email_verified:
return "Email <i>(unconfirmed)</i>"
return obj.get_kind_display()
formatted_kind.short_description = "Kind"
def kind_(self, obj):
return f'<span class="icon-{ obj.kind }"></span> &nbsp; {obj.kind}'
def num_notifications(self, obj): def num_notifications(self, obj):
return obj.notification__count return obj.notification__count


+ 5
- 1
templates/admin/base_site.html View File

@ -1,7 +1,11 @@
{% extends "admin/base_site.html" %} {% extends "admin/base_site.html" %}
{% load hc_extras %}
{% load hc_extras static %}
{% block title %}{% site_name %} Administration{% endblock %} {% block title %}{% site_name %} Administration{% endblock %}
{% block extrastyle %}
<link rel="stylesheet" href="{% static 'css/icomoon.css' %}" type="text/css">
{% endblock %}
{% block branding %} {% block branding %}
<h1 id="site-name"> <h1 id="site-name">
<a href="{% url 'admin:index' %}">{% site_name %}</a> <a href="{% url 'admin:index' %}">{% site_name %}</a>


Loading…
Cancel
Save