forked from GithubBackups/healthchecks
Profile admin improvements
This commit is contained in:
parent
9d244931b3
commit
edb8b88d06
@ -56,10 +56,14 @@ class ProfileAdmin(admin.ModelAdmin):
|
||||
})
|
||||
|
||||
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>
|
||||
%d of %d
|
||||
""" % (pct, num_checks, obj.check_limit)
|
||||
|
||||
def email(self, obj):
|
||||
return obj.user.email
|
||||
@ -70,14 +74,14 @@ class ProfileAdmin(admin.ModelAdmin):
|
||||
|
||||
class HcUserAdmin(UserAdmin):
|
||||
actions = ["send_report"]
|
||||
list_display = ('id', 'email', 'date_joined', 'involvement',
|
||||
list_display = ('id', 'email', 'date_joined', 'engagement',
|
||||
'is_staff', 'checks')
|
||||
|
||||
list_filter = ("last_login", "date_joined", "is_staff", "is_active")
|
||||
|
||||
ordering = ["-id"]
|
||||
|
||||
def involvement(self, user):
|
||||
def engagement(self, user):
|
||||
result = ""
|
||||
num_checks = Check.objects.filter(user=user).count()
|
||||
num_channels = Channel.objects.filter(user=user).count()
|
||||
@ -98,7 +102,7 @@ class HcUserAdmin(UserAdmin):
|
||||
|
||||
return result
|
||||
|
||||
involvement.allow_tags = True
|
||||
engagement.allow_tags = True
|
||||
|
||||
def checks(self, user):
|
||||
url = reverse("hc-switch-team", args=[user.username])
|
||||
|
@ -7,4 +7,24 @@
|
||||
|
||||
.field-users ul li {
|
||||
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…
x
Reference in New Issue
Block a user