aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/admin.py
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-01-25 14:39:26 +0000
committerMatthew Lemon <lemon@matthewlemon.com>2020-01-25 14:39:26 +0000
commit5a61862454339b61bd4ab50399ac1d683fb2b564 (patch)
tree5e67cc44dffad34fd6288fd7200b095f2e049544 /ctrack/organisations/admin.py
parentc488ad804bcc7c3febee3bea2089b86bbe419bbb (diff)
Better admin
Diffstat (limited to '')
-rw-r--r--ctrack/organisations/admin.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/ctrack/organisations/admin.py b/ctrack/organisations/admin.py
index f8ad2aa..5ae61d5 100644
--- a/ctrack/organisations/admin.py
+++ b/ctrack/organisations/admin.py
@@ -1,6 +1,15 @@
from django.contrib import admin
-from .models import Organisation, Address, AddressType
+from .models import Organisation, Address, AddressType, Person, Role
+
+
+# So we can get the organisation name - a reverse lookup
+def get_organisation_name(person):
+ return Organisation.objects.filter(person__name=person).first().name
+
+
+# We need this to ensure the column header in the admin does't read the func name
+get_organisation_name.short_description = 'Organisation'
class AddressTypeAdmin(admin.ModelAdmin):
@@ -15,9 +24,20 @@ class AddressInLine(admin.StackedInline):
class OrganisationAdmin(admin.ModelAdmin):
inlines = [AddressInLine,]
- list_display = ('slug', 'name')
+ list_display = ('name',)
+
+
+class PersonAdmin(admin.ModelAdmin):
+ model = Person
+ list_display = ['name', get_organisation_name, 'email', 'mobile']
+
+
+class RoleAdmin(admin.ModelAdmin):
+ model = Role
# Register your models here.
admin.site.register(Organisation, OrganisationAdmin)
admin.site.register(AddressType, AddressTypeAdmin)
+admin.site.register(Role, RoleAdmin)
+admin.site.register(Person, PersonAdmin)