summaryrefslogblamecommitdiffstats
path: root/engagements/admin.py
blob: 3b9d05c1515283e3f0b51bae76c247624dcae3ad (plain) (tree)
1
2
3
4
5
6
7
8
9
10





                                
                       


                        
                    







                                                        



                                                







                                                  








                                             



                                  
                                                    
                             
                                                          

                               
from django.contrib import admin

from .models import (
    Engagement,
    EngagementEffort,
    EngagementType,
    EngagementStrategy,
    Organisation,
    Person,
    RegulatedEntityType,
    RegulatoryCycle,
    RegulatoryRole,
)

site = admin.site

site.site_header = "DefNucSyR Engagement Database (DED)"


class EngagementStrategyAdmin(admin.ModelAdmin):
    list_display = ("__str__", "owned_by")


class PersonAdmin(admin.ModelAdmin):
    list_display = ("__str__", "organisation")

    @admin.display(description="fullname")
    def fullname(self, obj):
        return f"{obj.first_name} {obj.last_name}"


class RegulatoryCycleAdmin(admin.ModelAdmin):
    @admin.display(description="year")
    def year(self, obj):
        return f"{obj.get_year()}"

    list_display = ("__str__", "year")
    ordering = ("-start_date",)


site.register(Person, PersonAdmin)
site.register(Organisation)
site.register(RegulatedEntityType)
site.register(RegulatoryRole)
site.register(RegulatoryCycle, RegulatoryCycleAdmin)
site.register(EngagementType)
site.register(EngagementStrategy, EngagementStrategyAdmin)
site.register(Engagement)
site.register(EngagementEffort)