aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/caf/admin.py
blob: 551378113c0d2c7a82ef22c984bd5dc66999e718 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from django.contrib import admin

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", get_system_org, "function"]


# FIXME
# class ApplicableSystemAdmin(admin.StackedInline):
#     model = ApplicableSystem
#     max_num = 3
#     extra = 1


# 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 = ["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)
admin.site.register(ApplicableSystem, ApplicableSystemListAdmin)