Fix DMS entity assignment and Geschichte document linking
- DMS edit view: add Destinatär, Land, Pächter, Verpachtung dropdowns so documents can be assigned to entities after upload - Geschichte: add M2M dokumente field on GeschichteSeite model - Geschichte form: checkboxes to select/link Stiftungsgeschichte docs - Geschichte detail: show linked documents in sidebar with download Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -99,12 +99,19 @@ def geschichte_create(request):
|
||||
seite.erstellt_von = request.user
|
||||
seite.aktualisiert_von = request.user
|
||||
seite.save()
|
||||
|
||||
form.save_m2m()
|
||||
|
||||
# Link selected DMS documents
|
||||
dok_ids = request.POST.getlist("dokument_ids")
|
||||
if dok_ids:
|
||||
from stiftung.models import DokumentDatei
|
||||
seite.dokumente.set(DokumentDatei.objects.filter(pk__in=dok_ids))
|
||||
|
||||
messages.success(request, f'Geschichtsseite "{seite.titel}" wurde erfolgreich erstellt.')
|
||||
return redirect('stiftung:geschichte_detail', slug=seite.slug)
|
||||
else:
|
||||
form = GeschichteSeiteForm()
|
||||
|
||||
|
||||
# Verfuegbare Stiftungsgeschichte-Dokumente aus DMS
|
||||
from stiftung.models import DokumentDatei
|
||||
geschichte_dokumente = DokumentDatei.objects.filter(
|
||||
@@ -115,6 +122,7 @@ def geschichte_create(request):
|
||||
'form': form,
|
||||
'title': 'Neue Geschichtsseite',
|
||||
'geschichte_dokumente': geschichte_dokumente,
|
||||
'selected_dok_ids': [],
|
||||
}
|
||||
|
||||
return render(request, 'stiftung/geschichte/form.html', context)
|
||||
@@ -135,23 +143,33 @@ def geschichte_edit(request, slug):
|
||||
seite = form.save(commit=False)
|
||||
seite.aktualisiert_von = request.user
|
||||
seite.save()
|
||||
|
||||
form.save_m2m()
|
||||
|
||||
# Update linked DMS documents
|
||||
dok_ids = request.POST.getlist("dokument_ids")
|
||||
from stiftung.models import DokumentDatei
|
||||
seite.dokumente.set(DokumentDatei.objects.filter(pk__in=dok_ids))
|
||||
|
||||
messages.success(request, f'Geschichtsseite "{seite.titel}" wurde erfolgreich aktualisiert.')
|
||||
return redirect('stiftung:geschichte_detail', slug=seite.slug)
|
||||
else:
|
||||
form = GeschichteSeiteForm(instance=seite)
|
||||
|
||||
|
||||
# Verfuegbare Stiftungsgeschichte-Dokumente aus DMS
|
||||
from stiftung.models import DokumentDatei
|
||||
geschichte_dokumente = DokumentDatei.objects.filter(
|
||||
kontext="stiftungsgeschichte"
|
||||
).order_by("-erstellt_am")[:20]
|
||||
|
||||
# IDs der bereits verknuepften Dokumente
|
||||
selected_dok_ids = list(seite.dokumente.values_list("pk", flat=True))
|
||||
|
||||
context = {
|
||||
'form': form,
|
||||
'seite': seite,
|
||||
'title': f'Bearbeiten: {seite.titel}',
|
||||
'geschichte_dokumente': geschichte_dokumente,
|
||||
'selected_dok_ids': selected_dok_ids,
|
||||
}
|
||||
|
||||
return render(request, 'stiftung/geschichte/form.html', context)
|
||||
|
||||
Reference in New Issue
Block a user