Browse Source

In admin, visualize account's number of checks

pull/399/head
Pēteris Caune 4 years ago
parent
commit
e89229a2ca
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
  1. 6
      hc/accounts/admin.py
  2. 12
      static/css/admin/profiles.css
  3. 9
      templates/admin/profile_list_projects.html

6
hc/accounts/admin.py

@ -72,6 +72,7 @@ class NumChecksFilter(admin.SimpleListFilter):
def lookups(self, request, model_admin):
return (
("10", "more than 10"),
("20", "more than 20"),
("50", "more than 50"),
("100", "more than 100"),
@ -129,7 +130,10 @@ class ProfileAdmin(admin.ModelAdmin):
def email(self, obj):
s = escape(obj.user.email)
if obj.plan:
return "<span title='%s'>%s</span>" % (obj.plan, s)
s = "<span title='%s'>%s</span>" % (obj.plan, s)
v = min(30, obj.num_checks) * 8
s += """<div class="nchecks"><div style="width: %dpx"></div>""" % v
return s

12
static/css/admin/profiles.css

@ -11,3 +11,15 @@
.field-email span {
border-bottom: 2px solid #FFEB3B;
}
.nchecks {
margin-top: 4px;
width: 240px;
height: 7px;
background-image: url(data:image/gif;base64,R0lGODlh8AABAKECAN3d3e7u7v///////yH5BAEKAAMALAAAAADwAAEAAAImhA+Cp5v+XFsTVQav0ZHmL4FeSFLBiQZCiq6s+sKvy9Kp3cb4KRQAOw==);
}
.nchecks div {
background-image: url(data:image/gif;base64,R0lGODlhCAABAKEBAHmuyP///////////yH5BAEKAAIALAAAAAAIAAEAAAIDhA9RADs=);
height: 7px;
}

9
templates/admin/profile_list_projects.html

@ -2,15 +2,6 @@
{% for project in profile.user.project_set.all %}
<li>
<a href="{% url 'hc-checks' project.code %}">{{ project }}</a>
{% if profile.num_checks > 1 %}
{% with project.num_checks as n %}
{% if n > 1 %}
<strong>({{ n }})</strong>
{% else %}
({{ n }})
{% endif %}
{% endwith %}
{% endif %}
</li>
{% endfor %}
</ul>
Loading…
Cancel
Save