fix: Matrix-Faerbung bei rating ±3 / ±4 / ±5 inkonsistent

User-Bug-Report: "+ mal blassrot, ++ mal blassgruen oder gruen".

Ursache: matrix_mini-Macro hatte rating_class() nur fuer
rating ∈ {-2, -1, 0, 1, 2} definiert. Aber die echte
Bewertungs-Skala ist −5..+5 (siehe app/models.py:MatrixEntry).

Effekt:
- rating=3, symbol="+" → m-0 neutral angezeigt (sollte m-p gruen sein)
- rating=4, symbol="++" → m-0 neutral (sollte m-pp ECG-Gruen)
- rating=-3, symbol="−" → m-0 neutral (sollte m-n rot)
- rating=-4, symbol="−−" → m-0 neutral (sollte m-nn dunkelrot)

Fix: rating_class abdeckt jetzt die volle Skala −5..+5 analog
zu MatrixEntry.to_symbol():
- rating ≥  4  → m-pp
- rating  1..3 → m-p
- rating  0    → m-0
- rating -1..-3→ m-n
- rating ≤ -4  → m-nn

Doku im Macro-Header korrigiert (war "-2 bis 2", jetzt "-5 bis +5").

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dotty Dotter 2026-05-03 22:51:24 +02:00
parent cbc303f765
commit 6e78e92ddf

View File

@ -3,15 +3,20 @@
Props: Props:
matrix : Dict mit Schlüsseln A1E5, je Wert ein Dict: matrix : Dict mit Schlüsseln A1E5, je Wert ein Dict:
{ "rating": int (-2 bis 2), "symbol": str ("++"|"+"|"○"|""|"") } { "rating": int (-5 bis +5), "symbol": str ("++"|"+"|"○"|""|"") }
Fehlende Felder werden als neutral (○) dargestellt. Fehlende Felder werden als neutral (○) dargestellt.
Farbstufen-Klassen (CSS in v2.css): Mapping rating → Symbol → Farbklasse (vgl. models.py:MatrixEntry.to_symbol):
m-pp : rating 2 (++ stark fördernd) — ECG-Grün auf Weiß rating ≥ 4 → "++" → m-pp (ECG-Grün)
m-p : rating 1 (+ fördernd) — Grün-Tint rating 1..3 → "+" → m-p (Grün-Tint)
m-0 : rating 0 (○ neutral) — Weiß rating 0 → "○" → m-0 (Weiß)
m-n : rating -1 ( widersprechend) — Rot-Tint rating -1..-3→ "" → m-n (Rot-Tint)
m-nn : rating -2 ( stark widerspr.)— Dunkelrot rating ≤ -4 → "" → m-nn (Dunkelrot)
Vorher (Bug): Macro mappte nur rating ∈ {-2,-1,0,1,2}, was bei
rating ∈ {3,4,-3,-4,-5} zu inkonsistenter Faerbung fuehrte —
z.B. "+" mit rating=3 → m-0 neutral statt m-p gruen.
Jetzt: Mapping deckt die volle Skala 5..+5 ab.
Verwendung: Verwendung:
{% from "v2/components/matrix_mini.html" import matrix_mini %} {% from "v2/components/matrix_mini.html" import matrix_mini %}
@ -51,11 +56,11 @@
} %} } %}
{% macro rating_class(r) %} {% macro rating_class(r) %}
{% if r == 2 %}m-pp {% if r is none or r == 0 %}m-0
{% elif r == 1 %}m-p {% elif r >= 4 %}m-pp
{% elif r == -1 %}m-n {% elif r >= 1 %}m-p
{% elif r == -2 %}m-nn {% elif r <= -4 %}m-nn
{% else %}m-0{% endif %} {% else %}m-n{% endif %}
{% endmacro %} {% endmacro %}
<div class="v2-matrix-mini" role="table" aria-label="GWÖ-Matrix 5×5"> <div class="v2-matrix-mini" role="table" aria-label="GWÖ-Matrix 5×5">