mpeltriaux
b0f3505972
* removes admin backend views which are not important for production * adds filtering functionalities on index views * simplifies detail views on intervention, compensation, ecoaccount and ema * adds autocomplete fields on detail views * adds handy horizontal filter fields on detail views
77 lines
1.7 KiB
Python
77 lines
1.7 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"
|
|
]
|
|
|
|
def get_fields(self, request, obj=None):
|
|
return super().get_fields(request, obj) + [
|
|
"identifier",
|
|
"title",
|
|
"comment",
|
|
"checked",
|
|
"recorded",
|
|
"users",
|
|
]
|
|
|
|
def get_readonly_fields(self, request, obj=None):
|
|
return super().get_readonly_fields(request, obj) + [
|
|
"checked",
|
|
"recorded",
|
|
]
|
|
|
|
|
|
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)
|