mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-08 06:30:05 +00:00
Admin improvements
This commit is contained in:
parent
2185fe1463
commit
b0f8763465
4 changed files with 39 additions and 5 deletions
|
@ -2,6 +2,7 @@ from django.contrib import admin
|
|||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.template.loader import render_to_string
|
||||
from hc.accounts.models import Profile
|
||||
from hc.api.models import Channel, Check
|
||||
|
||||
|
@ -9,12 +10,26 @@ from hc.api.models import Channel, Check
|
|||
@admin.register(Profile)
|
||||
class ProfileAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ("id", "email", "reports_allowed", "next_report_date",
|
||||
"ping_log_limit")
|
||||
search_fields = ["user__email"]
|
||||
class Media:
|
||||
css = {
|
||||
'all': ('css/admin/profiles.css',)
|
||||
}
|
||||
|
||||
def email(self, obj):
|
||||
return obj.user.email
|
||||
list_display = ("id", "users", "reports_allowed", "next_report_date",
|
||||
"ping_log_limit")
|
||||
search_fields = ["id", "user__email"]
|
||||
list_filter = ("reports_allowed", "team_access_allowed",
|
||||
"next_report_date")
|
||||
|
||||
def users(self, obj):
|
||||
if obj.member_set.count() == 0:
|
||||
return obj.user.email
|
||||
else:
|
||||
return render_to_string("admin/profile_list_team.html", {
|
||||
"profile": obj
|
||||
})
|
||||
|
||||
users.allow_tags = True
|
||||
|
||||
|
||||
class HcUserAdmin(UserAdmin):
|
||||
|
|
|
@ -8,5 +8,8 @@ class SubsAdmin(admin.ModelAdmin):
|
|||
list_display = ("id", "email", "customer_id",
|
||||
"payment_method_token", "subscription_id", "plan_id")
|
||||
|
||||
list_filter = ("plan_id", )
|
||||
|
||||
|
||||
def email(self, obj):
|
||||
return obj.user.email if obj.user else None
|
||||
|
|
10
static/css/admin/profiles.css
Normal file
10
static/css/admin/profiles.css
Normal file
|
@ -0,0 +1,10 @@
|
|||
.field-users ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.field-users ul li {
|
||||
list-style-type: none;
|
||||
}
|
6
templates/admin/profile_list_team.html
Normal file
6
templates/admin/profile_list_team.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{{ profile.user.email }}
|
||||
<ul>
|
||||
{% for member in profile.member_set.all %}
|
||||
<li>{{ member.user.email }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
Loading…
Add table
Reference in a new issue