diff --git a/hc/accounts/admin.py b/hc/accounts/admin.py index 6985c154..0e79f05f 100644 --- a/hc/accounts/admin.py +++ b/hc/accounts/admin.py @@ -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", + class Media: + css = { + 'all': ('css/admin/profiles.css',) + } + + list_display = ("id", "users", "reports_allowed", "next_report_date", "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): diff --git a/hc/payments/admin.py b/hc/payments/admin.py index 4b95c3c2..fbf9a00a 100644 --- a/hc/payments/admin.py +++ b/hc/payments/admin.py @@ -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 diff --git a/static/css/admin/profiles.css b/static/css/admin/profiles.css new file mode 100644 index 00000000..cc571bf5 --- /dev/null +++ b/static/css/admin/profiles.css @@ -0,0 +1,10 @@ +.field-users ul { + list-style: none; + margin: 0; + padding: 0; + color: #888; +} + +.field-users ul li { + list-style-type: none; +} \ No newline at end of file diff --git a/templates/admin/profile_list_team.html b/templates/admin/profile_list_team.html new file mode 100644 index 00000000..246f0ed6 --- /dev/null +++ b/templates/admin/profile_list_team.html @@ -0,0 +1,6 @@ +{{ profile.user.email }} + \ No newline at end of file