konova/intervention/admin.py
mpeltriaux 1af807deae # Remove view
* refactors remove view methods into classes
* introduced AbstractRemoveView
* disables final-delete actions from admin views
* extends error warnings on RemoveEcoAccountModalForm
* removes LoginRequiredMixin from AbstractPublicReportView to make it accessible for the public
* updates translations
2025-12-14 17:37:01 +01:00

89 lines
2.1 KiB
Python

from django.contrib import admin
from intervention.models import Intervention, Responsibility, Legal, Revocation, InterventionDocument
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)