2021-07-22 13:19:14 +02:00
|
|
|
"""
|
|
|
|
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
|
|
|
|
|
2022-01-04 16:25:17 +01:00
|
|
|
from konova.models import Geometry, Deadline, GeometryConflict, Parcel, District
|
2022-02-03 15:29:22 +01:00
|
|
|
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE
|
|
|
|
from user.models import UserAction
|
2021-07-22 13:19:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
class GeometryAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
"id",
|
2021-08-02 11:52:20 +02:00
|
|
|
"created",
|
2021-07-22 13:19:14 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-01-04 16:25:17 +01:00
|
|
|
class ParcelAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
"id",
|
2022-01-05 14:13:26 +01:00
|
|
|
"gmrkng",
|
2022-01-04 16:25:17 +01:00
|
|
|
"flr",
|
|
|
|
"flrstck_nnr",
|
|
|
|
"flrstck_zhlr",
|
|
|
|
"updated_on",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class DistrictAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
"id",
|
|
|
|
"gmnd",
|
|
|
|
"krs",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2021-12-15 13:59:52 +01:00
|
|
|
class GeometryConflictAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
"conflicting_geometry",
|
2021-12-16 09:58:59 +01:00
|
|
|
"affected_geometry",
|
2021-12-15 13:59:52 +01:00
|
|
|
"detected_on",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2021-09-01 16:24:49 +02:00
|
|
|
class AbstractDocumentAdmin(admin.ModelAdmin):
|
2021-07-23 16:04:58 +02:00
|
|
|
list_display = [
|
|
|
|
"id",
|
|
|
|
"title",
|
|
|
|
"comment",
|
2021-08-02 11:52:20 +02:00
|
|
|
"created",
|
2021-07-23 16:04:58 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2021-07-30 12:20:23 +02:00
|
|
|
class DeadlineAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
"id",
|
|
|
|
"type",
|
|
|
|
"date",
|
|
|
|
"comment",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-02-01 18:41:02 +01:00
|
|
|
class BaseResourceAdmin(admin.ModelAdmin):
|
|
|
|
fields = [
|
|
|
|
"created",
|
|
|
|
"modified",
|
|
|
|
]
|
2021-12-15 13:59:52 +01:00
|
|
|
readonly_fields = [
|
|
|
|
"modified",
|
|
|
|
"created",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-02-01 18:41:02 +01:00
|
|
|
class BaseObjectAdmin(BaseResourceAdmin):
|
|
|
|
search_fields = [
|
|
|
|
"identifier",
|
|
|
|
"title",
|
|
|
|
]
|
2022-02-03 15:29:22 +01:00
|
|
|
actions = [
|
|
|
|
"restore_deleted_data"
|
|
|
|
]
|
2022-02-01 18:41:02 +01:00
|
|
|
|
|
|
|
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",
|
|
|
|
]
|
|
|
|
|
2022-02-03 15:29:22 +01:00
|
|
|
def restore_deleted_data(self, request, queryset):
|
|
|
|
queryset = queryset.filter(
|
|
|
|
deleted__isnull=False
|
|
|
|
)
|
|
|
|
for entry in queryset:
|
|
|
|
entry.deleted.delete()
|
|
|
|
|
|
|
|
|
2022-02-01 18:41:02 +01:00
|
|
|
|
|
|
|
# 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)
|