Browse Source

Admin improvements

pull/64/head
Pēteris Caune 9 years ago
parent
commit
b0f8763465
4 changed files with 38 additions and 4 deletions
  1. +19
    -4
      hc/accounts/admin.py
  2. +3
    -0
      hc/payments/admin.py
  3. +10
    -0
      static/css/admin/profiles.css
  4. +6
    -0
      templates/admin/profile_list_team.html

+ 19
- 4
hc/accounts/admin.py View File

@ -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:
css = {
'all': ('css/admin/profiles.css',)
}
list_display = ("id", "users", "reports_allowed", "next_report_date",
"ping_log_limit") "ping_log_limit")
search_fields = ["user__email"]
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
})
def email(self, obj):
return obj.user.email
users.allow_tags = True
class HcUserAdmin(UserAdmin): class HcUserAdmin(UserAdmin):


+ 3
- 0
hc/payments/admin.py View File

@ -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
- 0
static/css/admin/profiles.css View 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
- 0
templates/admin/profile_list_team.html View File

@ -0,0 +1,6 @@
{{ profile.user.email }}
<ul>
{% for member in profile.member_set.all %}
<li>{{ member.user.email }}</li>
{% endfor %}
</ul>

Loading…
Cancel
Save