99 lines
2.6 KiB
Python
99 lines
2.6 KiB
Python
from django.contrib import admin
|
|
|
|
from .models import (
|
|
CmsRedRiverVeteransScholarship,
|
|
CertificationDefinition,
|
|
Certification,
|
|
CertificationVersion,
|
|
InstructorOrVendor,
|
|
SpecialProgram,
|
|
Waiver,
|
|
)
|
|
|
|
|
|
class CertificationVersionInline(admin.TabularInline):
|
|
model = CertificationVersion
|
|
extra = 1
|
|
|
|
|
|
@admin.register(CertificationVersion)
|
|
class CertificationVersionAdmin(admin.ModelAdmin):
|
|
search_fields = ["definition__certification_name", "version"]
|
|
list_display = ["definition", "version"]
|
|
list_filter = ["definition__department", "definition__certification_name"]
|
|
|
|
|
|
@admin.register(CertificationDefinition)
|
|
class CertificationDefinitionAdmin(admin.ModelAdmin):
|
|
search_fields = ["certification_name"]
|
|
list_display = ["certification_name", "department"]
|
|
list_filter = ["department"]
|
|
inlines = [CertificationVersionInline]
|
|
|
|
|
|
@admin.register(Certification)
|
|
class CertificationAdmin(admin.ModelAdmin):
|
|
search_fields = [
|
|
"name",
|
|
"certification__certification_name",
|
|
"certification__department",
|
|
]
|
|
autocomplete_fields = ["member"]
|
|
exclude = ["shop_lead_notified"]
|
|
|
|
@admin.display(
|
|
description="Certification Name",
|
|
ordering="certification_version__definition__certification_name",
|
|
)
|
|
def certification_name(self, obj):
|
|
return obj.certification_version.definition.certification_name
|
|
|
|
@admin.display(
|
|
description="Certification Version", ordering="certification_version__version"
|
|
)
|
|
def certification_version_version(self, obj):
|
|
return obj.certification_version.version
|
|
|
|
@admin.display(
|
|
description="Department",
|
|
ordering="certification_version__definition__department",
|
|
)
|
|
def certification_department(self, obj):
|
|
return obj.certification_version.definition.department
|
|
|
|
list_display = [
|
|
"certification_name",
|
|
"name",
|
|
"certification_version_version",
|
|
"certification_department",
|
|
"date",
|
|
"shop_lead_notified",
|
|
"certified_by",
|
|
]
|
|
list_display_links = [
|
|
"certification_name",
|
|
"name",
|
|
]
|
|
list_filter = [
|
|
"certification_version__definition__department",
|
|
("shop_lead_notified", admin.EmptyFieldListFilter),
|
|
]
|
|
|
|
|
|
@admin.register(InstructorOrVendor)
|
|
class InstructorOrVendorAdmin(admin.ModelAdmin):
|
|
search_fields = ["name"]
|
|
|
|
|
|
@admin.register(SpecialProgram)
|
|
class SpecialProgramAdmin(admin.ModelAdmin):
|
|
search_fields = ["program_name"]
|
|
|
|
|
|
@admin.register(Waiver)
|
|
class WaiverAdmin(admin.ModelAdmin):
|
|
search_fields = ["name"]
|
|
|
|
|
|
admin.site.register(CmsRedRiverVeteransScholarship)
|