diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-09-02 12:04:19 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-09-02 12:04:19 +0100 |
commit | edd91cb77191b386af95dfaca0b2706c7ee143b9 (patch) | |
tree | b94edf8e069911d0aea4e1acfc23a72a180cb2cf /ctrack/caf/admin.py | |
parent | 15c89a78c097dc00ad7b8ca3314581ed3b058187 (diff) | |
parent | c406d3da83d20d65c2fc4da7d5d4d5db0f6ad115 (diff) |
Merge branch 'db_rewrite' into master
Diffstat (limited to 'ctrack/caf/admin.py')
-rw-r--r-- | ctrack/caf/admin.py | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/ctrack/caf/admin.py b/ctrack/caf/admin.py index f19e8f4..5513781 100644 --- a/ctrack/caf/admin.py +++ b/ctrack/caf/admin.py @@ -1,31 +1,56 @@ from django.contrib import admin -from .models import CAF, FileStore, DocumentFile, Grading, ApplicableSystem +from .models import ( + CAF, + FileStore, + DocumentFile, + Grading, + ApplicableSystem, + EssentialService, +) + + +def get_system_org(obj): + es = obj.essentialservice_set.first() # just get the first if there are many + return es.organisation.name + + +get_system_org.short_description = "Organisation" + + +class EssentialServiceAdmin(admin.ModelAdmin): + model = EssentialService class ApplicableSystemListAdmin(admin.ModelAdmin): model = ApplicableSystem - list_display = ["name", "organisation", "caf"] + list_display = ["name", get_system_org, "function"] -class ApplicableSystemAdmin(admin.StackedInline): - model = ApplicableSystem - max_num = 3 - extra = 1 +# FIXME +# class ApplicableSystemAdmin(admin.StackedInline): +# model = ApplicableSystem +# max_num = 3 +# extra = 1 -def get_caf_name(obj): - ass = ApplicableSystem.objects.filter(caf=obj).first() - return f"{ass.organisation.name}_v{obj.version}" +# FIXME - NOT NEEDED +# def get_caf_name(obj): +# ass = ApplicableSystem.objects.filter(caf=obj).first() +# return f"{ass.organisation.name}_v{obj.version}" +# FIXME class CAFAdmin(admin.ModelAdmin): model = CAF - inlines = [ApplicableSystemAdmin] - list_display = [get_caf_name, "quality_grading", "confidence_grading", "file"] + # inlines = [ApplicableSystemAdmin] + + +# list_display = ["quality_grading", "confidence_grading", "file"] admin.site.register(CAF, CAFAdmin) +admin.site.register(EssentialService, EssentialServiceAdmin) admin.site.register(FileStore) admin.site.register(DocumentFile) admin.site.register(Grading) |