feat: Add LandVerpachtung to Django admin interface
- Register LandVerpachtung model in admin for easy production verification - Add comprehensive list display with status, dates, and relationships - Include colored status display and proper fieldsets - Enables verification of Verpachtung functionality in production
This commit is contained in:
@@ -7,7 +7,7 @@ from django.utils.safestring import mark_safe
|
||||
from . import models
|
||||
from .models import (AppConfiguration, AuditLog, BackupJob, BankTransaction,
|
||||
CSVImport, Destinataer, DestinataerUnterstuetzung,
|
||||
DokumentLink, Foerderung, Land, Paechter, Person,
|
||||
DokumentLink, Foerderung, Land, LandVerpachtung, Paechter, Person,
|
||||
Rentmeister, StiftungsKonto, UnterstuetzungWiederkehrend,
|
||||
Verwaltungskosten)
|
||||
|
||||
@@ -304,6 +304,59 @@ class LandAdmin(admin.ModelAdmin):
|
||||
verpachtungsgrad_berechnet.short_description = "Verpachtungsgrad"
|
||||
|
||||
|
||||
@admin.register(LandVerpachtung)
|
||||
class LandVerpachtungAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"land",
|
||||
"paechter",
|
||||
"pachtpreis_qm",
|
||||
"laufzeit_von",
|
||||
"laufzeit_bis",
|
||||
"status_display",
|
||||
"erstellt_am",
|
||||
]
|
||||
list_filter = ["status", "laufzeit_von", "laufzeit_bis", "erstellt_am"]
|
||||
search_fields = ["land__lfd_nr", "land__gemeinde", "paechter__vorname", "paechter__nachname"]
|
||||
ordering = ["-erstellt_am"]
|
||||
readonly_fields = ["id", "erstellt_am", "aktualisiert_am"]
|
||||
|
||||
fieldsets = (
|
||||
("Verpachtungsdetails", {
|
||||
"fields": ("land", "paechter", "pachtpreis_qm", "status")
|
||||
}),
|
||||
("Laufzeit", {
|
||||
"fields": ("laufzeit_von", "laufzeit_bis", "kuendigungsfrist_monate")
|
||||
}),
|
||||
("Finanziell", {
|
||||
"fields": ("kaution", "indexierung", "zahlungsintervall")
|
||||
}),
|
||||
("Zusatzinformationen", {
|
||||
"fields": ("notizen", "besondere_vereinbarungen"),
|
||||
"classes": ("collapse",)
|
||||
}),
|
||||
("System", {
|
||||
"fields": ("id", "erstellt_am", "aktualisiert_am"),
|
||||
"classes": ("collapse",)
|
||||
}),
|
||||
)
|
||||
|
||||
def status_display(self, obj):
|
||||
colors = {
|
||||
'aktiv': 'green',
|
||||
'beendet': 'red',
|
||||
'geplant': 'orange',
|
||||
'gekündigt': 'red'
|
||||
}
|
||||
color = colors.get(obj.status, 'black')
|
||||
return format_html(
|
||||
'<span style="color: {}; font-weight: bold;">{}</span>',
|
||||
color,
|
||||
obj.get_status_display()
|
||||
)
|
||||
|
||||
status_display.short_description = "Status"
|
||||
|
||||
|
||||
@admin.register(DokumentLink)
|
||||
class DokumentLinkAdmin(admin.ModelAdmin):
|
||||
list_display = ["titel", "kontext", "paperless_document_id"]
|
||||
|
||||
Reference in New Issue
Block a user