Files
konova/intervention/admin.py
T
mpeltriaux 6772ddb5c8 # Remove ExternalIdentifier
* adds removing of ExternalIdentifier entries if a BaseObject is removed from the database
* removes unused import statements
* adds ExternalIdentifier view to admin backend
2026-08-17 14:35:42 +02:00

89 lines
2.0 KiB
Python

from django.contrib import admin
from intervention.models import Intervention
from konova.admin import AbstractDocumentAdmin, BaseObjectAdmin
class InterventionAdmin(BaseObjectAdmin):
list_display = [
"id",
"identifier",
"title",
"created",
"deleted",
]
filter_horizontal = [
"users",
"teams",
]
def get_fields(self, request, obj=None):
return super().get_fields(request, obj) + [
"identifier",
"title",
"comment",
"checked",
"recorded",
"users",
"teams",
"geometry",
]
def get_readonly_fields(self, request, obj=None):
return super().get_readonly_fields(request, obj) + [
"checked",
"recorded",
"geometry",
]
def get_actions(self, request):
DELETE_ACTION_IDENTIFIER = "delete_selected"
actions = super().get_actions(request)
if DELETE_ACTION_IDENTIFIER in actions:
del actions[DELETE_ACTION_IDENTIFIER]
return actions
class InterventionDocumentAdmin(AbstractDocumentAdmin):
pass
class ResponsibilityAdmin(admin.ModelAdmin):
list_display = [
"id",
"registration_office",
"registration_file_number",
"conservation_office",
"conservation_file_number",
"handler",
]
class LegalAdmin(admin.ModelAdmin):
list_display = [
"id",
"process_type",
"registration_date",
"binding_date",
]
class RevocationAdmin(admin.ModelAdmin):
list_display = [
"id",
"date",
"comment",
"created",
]
admin.site.register(Intervention, InterventionAdmin)
# Outcommented for a cleaner admin backend on production
#admin.site.register(Responsibility, ResponsibilityAdmin)
#admin.site.register(Legal, LegalAdmin)
#admin.site.register(Revocation, RevocationAdmin)
#admin.site.register(InterventionDocument, InterventionDocumentAdmin)