Admin interface for Referenzen fixed
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Has been cancelled

This commit is contained in:
2026-02-09 08:37:47 +01:00
parent 27e78d6f39
commit 633ecabdb9
3 changed files with 10 additions and 13 deletions

View File

@@ -1,13 +1,9 @@
from django.contrib import admin from django.contrib import admin
#from nested_inline.admin import NestedStackedInline, NestedModelAdmin
from nested_admin import NestedStackedInline, NestedModelAdmin, NestedTabularInline
from django import forms from django import forms
from django.utils.html import format_html from django.utils.safestring import mark_safe
from mptt.forms import TreeNodeMultipleChoiceField
from mptt.admin import DraggableMPTTAdmin
from adminsortable2.admin import SortableInlineAdminMixin, SortableAdminBase from adminsortable2.admin import SortableInlineAdminMixin, SortableAdminBase
from mptt.forms import TreeNodeMultipleChoiceField
# Register your models here. from nested_admin import NestedStackedInline, NestedModelAdmin, NestedTabularInline
from .models import * from .models import *
from stichworte.models import Stichwort, Stichworterklaerung from stichworte.models import Stichwort, Stichworterklaerung
from referenzen.models import Referenz from referenzen.models import Referenz
@@ -165,7 +161,7 @@ class StichwortAdmin(NestedModelAdmin):
count = len(vorgaben_list) count = len(vorgaben_list)
if count == 0: if count == 0:
return format_html("<em>Keine Vorgaben gefunden</em><p><strong>Gesamt: 0 Vorgaben</strong></p>") return mark_safe("<em>Keine Vorgaben gefunden</em><p><strong>Gesamt: 0 Vorgaben</strong></p>")
html = "<div style='max-height: 300px; overflow-y: auto;'>" html = "<div style='max-height: 300px; overflow-y: auto;'>"
html += "<table style='width: 100%; border-collapse: collapse;'>" html += "<table style='width: 100%; border-collapse: collapse;'>"
@@ -186,7 +182,7 @@ class StichwortAdmin(NestedModelAdmin):
html += "</tbody></table>" html += "</tbody></table>"
html += f"</div><p><strong>Gesamt: {count} Vorgabe{'n' if count != 1 else ''}</strong></p>" html += f"</div><p><strong>Gesamt: {count} Vorgabe{'n' if count != 1 else ''}</strong></p>"
return format_html(html) return mark_safe(html)
vorgaben_list.short_description = "Zugeordnete Vorgaben" vorgaben_list.short_description = "Zugeordnete Vorgaben"
def get_queryset(self, request): def get_queryset(self, request):

View File

@@ -15,6 +15,7 @@
<h2>Checkliste</h2> <h2>Checkliste</h2>
<p>Die Checkliste wird unter anderem für Audits oder Prüfungen benutzt. Wir empfehlen allen Verantwortlichen, sie als internes Qualitätssicherungs-Hilfsmittel zu verwenden.</p>
<ul class="list-group"> <ul class="list-group">
{% for vorgabe in vorgaben %} {% for vorgabe in vorgaben %}
{% if vorgabe.checklistenfragen.all %} {% if vorgabe.checklistenfragen.all %}
@@ -25,4 +26,4 @@
{% endfor %} {% endfor %}
</ul> </ul>
</body> </body>
</html> </html>

View File

@@ -1,5 +1,5 @@
from django.contrib import admin from django.contrib import admin
from django.utils.html import format_html from django.utils.safestring import mark_safe
from nested_admin import NestedStackedInline, NestedModelAdmin, NestedTabularInline from nested_admin import NestedStackedInline, NestedModelAdmin, NestedTabularInline
from .models import * from .models import *
@@ -34,7 +34,7 @@ class ReferenzAdmin(NestedModelAdmin):
vorgaben_list = list(vorgaben) # Evaluate queryset once vorgaben_list = list(vorgaben) # Evaluate queryset once
count = len(vorgaben_list) count = len(vorgaben_list)
if count == 0: if count == 0:
return format_html("<em>Keine Vorgaben gefunden</em><p><strong>Gesamt: 0 Vorgaben</strong></p>") return mark_safe("<em>Keine Vorgaben gefunden</em><p><strong>Gesamt: 0 Vorgaben</strong></p>")
html = "<div style='max-height: 300px; overflow-y: auto;'>" html = "<div style='max-height: 300px; overflow-y: auto;'>"
html += "<table style='width: 100%; border-collapse: collapse;'>" html += "<table style='width: 100%; border-collapse: collapse;'>"
@@ -55,7 +55,7 @@ class ReferenzAdmin(NestedModelAdmin):
html += "</tbody></table>" html += "</tbody></table>"
html += f"</div><p><strong>Gesamt: {count} Vorgabe{'n' if count != 1 else ''}</strong></p>" html += f"</div><p><strong>Gesamt: {count} Vorgabe{'n' if count != 1 else ''}</strong></p>"
return format_html(html) return mark_safe(html)
vorgaben_list.short_description = "Zugeordnete Vorgaben" vorgaben_list.short_description = "Zugeordnete Vorgaben"