diff --git a/app/report.py b/app/report.py index b8d3570..6dc140f 100644 --- a/app/report.py +++ b/app/report.py @@ -590,6 +590,39 @@ async def generate_html_report_v3( assessment.drucksache, exc, ) + # Pre-compute Heuchelei-/Opportunismus-Marker pro Fraktion. + # Jinja-Globals sind im Web ``heuchelei_score`` und ``opportunismus_score``; + # sie erwarten Dict-Listen (fraktions_scores aus _row_to_detail). Das + # Pydantic-Assessment.wahlprogramm_scores hat dieselben Daten, aber als + # Pydantic-Objekte. Wir mappen einmal um und rechnen die Marker für + # alle abstimmenden Fraktionen, damit das Template nur noch Lookup + # statt Logik macht. + fraktions_scores_dict = [] + for fs in (assessment.wahlprogramm_scores or []): + fraktions_scores_dict.append({ + "fraktion": fs.fraktion, + "wahlprogramm": {"score": fs.wahlprogramm.score if fs.wahlprogramm else None}, + }) + + from .marker import heuchelei_score as _h, opportunismus_score as _o + heuchelei_by_fraktion: dict[str, float] = {} + opportunismus_by_fraktion: dict[str, float] = {} + if plenum_votes and fraktions_scores_dict: + seen: set[str] = set() + for v in plenum_votes: + for f in (v.get("fraktionen_nein") or []): + if f in seen: + continue + hv = _h(f, fraktions_scores_dict) + if hv is not None: + heuchelei_by_fraktion[f] = hv + for f in (v.get("fraktionen_ja") or []): + if f in seen: + continue + ov = _o(f, fraktions_scores_dict) + if ov is not None: + opportunismus_by_fraktion[f] = ov + template = _pdf_jinja.get_template("v3/pdf/antrag_pdf.html") html = template.render( assessment=assessment, @@ -602,6 +635,8 @@ async def generate_html_report_v3( plenum_votes=plenum_votes, konsistenz_state=konsistenz_state, konsistenz_decisive=konsistenz_decisive, + heuchelei_by_fraktion=heuchelei_by_fraktion, + opportunismus_by_fraktion=opportunismus_by_fraktion, ) output_path.write_text(html) diff --git a/app/templates/v3/pdf/antrag_pdf.html b/app/templates/v3/pdf/antrag_pdf.html index 4a9229b..5597a9e 100644 --- a/app/templates/v3/pdf/antrag_pdf.html +++ b/app/templates/v3/pdf/antrag_pdf.html @@ -504,6 +504,20 @@ background: rgba(45, 164, 78, 0.07); border-left-color: #2da44e; } + .pdf-marker { + font-weight: 700; + font-size: 9pt; + margin-left: 2pt; + } + .pdf-marker.heuchelei { color: #cf222e; } + .pdf-marker.opportunismus { color: #bf6c10; font-style: italic; } + .pdf-marker-legend { + font-size: 7.5pt; + color: #57606a; + margin-top: 4pt; + padding-top: 3pt; + border-top: 1pt dashed #d0d7de; + }
@@ -754,12 +768,12 @@