mpeltriaux
298a632cac
* adds more log details on adding/removing documents * fixes bug in admin backend where restoring of non-compensation entries led to an error * fixes bug where deleting of revocation without an attached file would lead to an error
110 lines
2.3 KiB
Python
110 lines
2.3 KiB
Python
"""
|
|
Author: Michel Peltriaux
|
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
|
Created on: 22.07.21
|
|
|
|
"""
|
|
from django.contrib import admin
|
|
|
|
from konova.models import Geometry, Deadline, GeometryConflict, Parcel, District
|
|
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE
|
|
from user.models import UserAction
|
|
|
|
|
|
class GeometryAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"created",
|
|
]
|
|
|
|
|
|
class ParcelAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"gmrkng",
|
|
"flr",
|
|
"flrstck_nnr",
|
|
"flrstck_zhlr",
|
|
"updated_on",
|
|
]
|
|
|
|
|
|
class DistrictAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"gmnd",
|
|
"krs",
|
|
]
|
|
|
|
|
|
class GeometryConflictAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"conflicting_geometry",
|
|
"affected_geometry",
|
|
"detected_on",
|
|
]
|
|
|
|
|
|
class AbstractDocumentAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"title",
|
|
"comment",
|
|
"created",
|
|
]
|
|
|
|
|
|
class DeadlineAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"type",
|
|
"date",
|
|
"comment",
|
|
]
|
|
|
|
|
|
class BaseResourceAdmin(admin.ModelAdmin):
|
|
fields = [
|
|
"created",
|
|
"modified",
|
|
]
|
|
readonly_fields = [
|
|
"modified",
|
|
"created",
|
|
]
|
|
|
|
|
|
class BaseObjectAdmin(BaseResourceAdmin):
|
|
search_fields = [
|
|
"identifier",
|
|
"title",
|
|
]
|
|
actions = [
|
|
"restore_deleted_data"
|
|
]
|
|
|
|
def get_fields(self, request, obj=None):
|
|
return super().get_fields(request, obj) + ["deleted"]
|
|
|
|
def get_readonly_fields(self, request, obj=None):
|
|
return super().get_readonly_fields(request, obj) + [
|
|
"deleted",
|
|
]
|
|
|
|
def restore_deleted_data(self, request, queryset):
|
|
queryset = queryset.filter(
|
|
deleted__isnull=False
|
|
)
|
|
for entry in queryset:
|
|
entry.deleted.delete()
|
|
|
|
|
|
|
|
# Outcommented for a cleaner admin backend on production
|
|
#admin.site.register(Geometry, GeometryAdmin)
|
|
#admin.site.register(Parcel, ParcelAdmin)
|
|
#admin.site.register(District, DistrictAdmin)
|
|
#admin.site.register(GeometryConflict, GeometryConflictAdmin)
|
|
#admin.site.register(Deadline, DeadlineAdmin)
|