forked from GithubBackups/healthchecks
Admin improvements
This commit is contained in:
parent
2185fe1463
commit
b0f8763465
@ -2,6 +2,7 @@ from django.contrib import admin
|
|||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.template.loader import render_to_string
|
||||||
from hc.accounts.models import Profile
|
from hc.accounts.models import Profile
|
||||||
from hc.api.models import Channel, Check
|
from hc.api.models import Channel, Check
|
||||||
|
|
||||||
@ -9,12 +10,26 @@ from hc.api.models import Channel, Check
|
|||||||
@admin.register(Profile)
|
@admin.register(Profile)
|
||||||
class ProfileAdmin(admin.ModelAdmin):
|
class ProfileAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ("id", "email", "reports_allowed", "next_report_date",
|
class Media:
|
||||||
"ping_log_limit")
|
css = {
|
||||||
search_fields = ["user__email"]
|
'all': ('css/admin/profiles.css',)
|
||||||
|
}
|
||||||
|
|
||||||
def email(self, obj):
|
list_display = ("id", "users", "reports_allowed", "next_report_date",
|
||||||
return obj.user.email
|
"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):
|
class HcUserAdmin(UserAdmin):
|
||||||
|
@ -8,5 +8,8 @@ class SubsAdmin(admin.ModelAdmin):
|
|||||||
list_display = ("id", "email", "customer_id",
|
list_display = ("id", "email", "customer_id",
|
||||||
"payment_method_token", "subscription_id", "plan_id")
|
"payment_method_token", "subscription_id", "plan_id")
|
||||||
|
|
||||||
|
list_filter = ("plan_id", )
|
||||||
|
|
||||||
|
|
||||||
def email(self, obj):
|
def email(self, obj):
|
||||||
return obj.user.email if obj.user else None
|
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…
x
Reference in New Issue
Block a user