Browse Source

Profile admin improvements

pull/125/head
Pēteris Caune 8 years ago
parent
commit
edb8b88d06
2 changed files with 32 additions and 8 deletions
  1. +11
    -7
      hc/accounts/admin.py
  2. +21
    -1
      static/css/admin/profiles.css

+ 11
- 7
hc/accounts/admin.py View File

@ -56,10 +56,14 @@ class ProfileAdmin(admin.ModelAdmin):
}) })
def checks(self, obj): def checks(self, obj):
current = Check.objects.filter(user=obj.user).count()
text = "%d of %d" % (current, obj.check_limit)
url = reverse("hc-switch-team", args=[obj.user.username])
return "<a href='%s'>%s</a>" % (url, text)
num_checks = Check.objects.filter(user=obj.user).count()
pct = 100 * num_checks / max(obj.check_limit, 1)
pct = min(100, int(pct))
return """
<span class="bar"><span style="width: %dpx"></span></span>
&nbsp; %d of %d
""" % (pct, num_checks, obj.check_limit)
def email(self, obj): def email(self, obj):
return obj.user.email return obj.user.email
@ -70,14 +74,14 @@ class ProfileAdmin(admin.ModelAdmin):
class HcUserAdmin(UserAdmin): class HcUserAdmin(UserAdmin):
actions = ["send_report"] actions = ["send_report"]
list_display = ('id', 'email', 'date_joined', 'involvement',
list_display = ('id', 'email', 'date_joined', 'engagement',
'is_staff', 'checks') 'is_staff', 'checks')
list_filter = ("last_login", "date_joined", "is_staff", "is_active") list_filter = ("last_login", "date_joined", "is_staff", "is_active")
ordering = ["-id"] ordering = ["-id"]
def involvement(self, user):
def engagement(self, user):
result = "" result = ""
num_checks = Check.objects.filter(user=user).count() num_checks = Check.objects.filter(user=user).count()
num_channels = Channel.objects.filter(user=user).count() num_channels = Channel.objects.filter(user=user).count()
@ -98,7 +102,7 @@ class HcUserAdmin(UserAdmin):
return result return result
involvement.allow_tags = True
engagement.allow_tags = True
def checks(self, user): def checks(self, user):
url = reverse("hc-switch-team", args=[user.username]) url = reverse("hc-switch-team", args=[user.username])


+ 21
- 1
static/css/admin/profiles.css View File

@ -7,4 +7,24 @@
.field-users ul li { .field-users ul li {
list-style-type: none; list-style-type: none;
}
}
.field-checks {
color: #888;
}
.bar {
display: inline-block;
width: 100px;
height: 10px;
border-radius: 5px;
overflow: hidden;
background: #ddd;
}
.bar span {
display: block;
height: 10px;
background: #79aec8;
}

Loading…
Cancel
Save