All files for deployment ready and tested - further development in this repo.

This commit is contained in:
2025-09-22 10:42:52 +02:00
parent 57b738e9ce
commit 12c3181ad2
394 changed files with 89982 additions and 0 deletions

0
stichworte/__init__.py Normal file
View File

3
stichworte/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
stichworte/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class StichworteConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'stichworte'

View File

@@ -0,0 +1,37 @@
# Generated by Django 5.2.5 on 2025-08-26 09:34
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('abschnitte', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Stichwort',
fields=[
('stichwort', models.CharField(max_length=50, primary_key=True, serialize=False)),
],
options={
'verbose_name_plural': 'Stichworte',
},
),
migrations.CreateModel(
name='Stichworterklaerung',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('inhalt', models.TextField(blank=True, null=True)),
('abschnitttyp', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='abschnitte.abschnitttyp')),
('erklaerung', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='stichworte.stichwort')),
],
options={
'verbose_name': 'Erklärung',
},
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.2.5 on 2025-08-27 09:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stichworte', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='stichworterklaerung',
name='order',
field=models.PositiveIntegerField(default=0),
),
]

View File

17
stichworte/models.py Normal file
View File

@@ -0,0 +1,17 @@
from django.db import models
from abschnitte.models import Textabschnitt
class Stichwort(models.Model):
stichwort = models.CharField(max_length=50, primary_key=True)
def __str__(self):
return self.stichwort
class Meta:
verbose_name_plural="Stichworte"
class Stichworterklaerung (Textabschnitt):
erklaerung = models.ForeignKey(Stichwort,on_delete=models.CASCADE)
class Meta:
verbose_name="Erklärung"

View File

@@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block title %}Stichwort: {{stichwort.stichwort}}{% endblock %}
{% block content %}
<h1>{{stichwort}}</h1>
{% if stichwort.erklaerung %}
<div class="card mb-4">
<div class="card-header d-flex justify-content-between align-items-center bg-secondary text-light">
<h3 class="h5 m-0">Beschreibung</h3>
</div>
<div class="card-body p-2">
{% for typ, html in stichwort.erklaerung %}
{% if html %}<div>{{ html|safe }}</div>{% endif %}{% endfor %}
</div>
</div>
{% endif %}
<div class="card mb-4">
<div class="card-header d-flex justify-content-between align-items-center bg-secondary text-light">
<h3 class="h5 m-0">Relevante Vorgaben</h3>
</div>
<div class="card-body p-2">
<ul>
{% for vorgabe in stichwort.vorgaben %}
{% if vorgabe.get_status == "active" %}
<li><a href="{% url 'standard_detail' nummer=vorgabe.dokument.nummer %}#{{vorgabe.Vorgabennummer}}">{{vorgabe.Vorgabennummer}}</a>: {{vorgabe.titel}}</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endblock %}

View File

@@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %}Stichworte{% endblock %}
{% block content %}
<h1>Stichworte</h1>
{% for Anfang, Worte in stichworte.items %}
<h2>{{ Anfang }}</h2>
<ul>
{% for Wort in Worte %}
<li><a href="{% url 'stichwort_detail' stichwort=Wort %}">{{ Wort }}</a></li>
{% endfor %}
</ul>
{% endfor %}
{% endblock %}

3
stichworte/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
stichworte/urls.py Normal file
View File

@@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.stichwort_list, name='stichworte_list'),
path('<str:stichwort>/',views.stichwort_detail, name="stichwort_detail")
]

19
stichworte/views.py Normal file
View File

@@ -0,0 +1,19 @@
from django.shortcuts import render
from abschnitte.utils import render_textabschnitte
from .models import Stichwort, Stichworterklaerung
from itertools import groupby
from django.db.models.functions import Lower
# Create your views here.
def stichwort_list(request):
qs = Stichwort.objects.order_by(Lower('stichwort'))
stichworte = {k: [o.stichwort for o in g] for k,g in groupby (qs, key=lambda o: o.stichwort[0].upper())}
return render(request, 'stichworte/stichwort_list.html', {'stichworte': stichworte})
def stichwort_detail(request, stichwort):
stichwort = Stichwort.objects.get(stichwort=stichwort)
stichwort.erklaerung = render_textabschnitte(stichwort.stichworterklaerung_set.order_by("order"))
stichwort.vorgaben = stichwort.vorgabe_set.all()
return render(request, "stichworte/stichwort_detail.html", {'stichwort': stichwort})