fix(orion): replace cover result box with compact status text
This commit is contained in:
parent
068d00513d
commit
85cd1c30ab
7 changed files with 75 additions and 7 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -8,7 +8,7 @@ from app.modules.orion.assets import schubamed_logo_uri
|
||||||
from app.modules.orion.components.base import ReportComponent
|
from app.modules.orion.components.base import ReportComponent
|
||||||
from app.modules.orion.context import ReportContext
|
from app.modules.orion.context import ReportContext
|
||||||
from app.modules.orion.html import definition_list, paragraph, section, table, text, yes_no
|
from app.modules.orion.html import definition_list, paragraph, section, table, text, yes_no
|
||||||
from app.modules.orion.result import validation_result_box, validation_result_label
|
from app.modules.orion.result import validation_result_box, validation_result_cover_sentence, validation_result_label
|
||||||
|
|
||||||
|
|
||||||
def render_template_text(content: str, context: ReportContext) -> str:
|
def render_template_text(content: str, context: ReportContext) -> str:
|
||||||
|
|
@ -84,7 +84,10 @@ class CoverComponent(ReportComponent):
|
||||||
f'<p class="cover-subtitle">{text(context.customer.name)}</p>'
|
f'<p class="cover-subtitle">{text(context.customer.name)}</p>'
|
||||||
f"{rows}"
|
f"{rows}"
|
||||||
'<div class="cover-closing">'
|
'<div class="cover-closing">'
|
||||||
f"{validation_result_box(validation.result)}"
|
'<div class="cover-result-text">'
|
||||||
|
"<h2>Ergebnis der Validierung</h2>"
|
||||||
|
f"<p>{text(validation_result_cover_sentence(validation.result))}</p>"
|
||||||
|
"</div>"
|
||||||
'<div class="signature-block"><div class="signature-line"></div><div class="signature-label">Unterschrift technische Validierung</div></div>'
|
'<div class="signature-block"><div class="signature-line"></div><div class="signature-label">Unterschrift technische Validierung</div></div>'
|
||||||
"</div>"
|
"</div>"
|
||||||
"</section>"
|
"</section>"
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,17 @@ def validation_result_label(value: str | None) -> str:
|
||||||
return validation_result_presentation(value).label
|
return validation_result_presentation(value).label
|
||||||
|
|
||||||
|
|
||||||
|
def validation_result_cover_sentence(value: str | None) -> str:
|
||||||
|
presentation = validation_result_presentation(value)
|
||||||
|
sentences = {
|
||||||
|
"BESTANDEN": "Die technische Validierung wurde erfolgreich bestanden.",
|
||||||
|
"BESTANDEN_MIT_AUFLAGEN": "Die technische Validierung wurde mit Auflagen bestanden.",
|
||||||
|
"NICHT_BESTANDEN": "Die technische Validierung wurde nicht bestanden.",
|
||||||
|
"OFFEN": "Die technische Validierung wurde noch nicht bewertet.",
|
||||||
|
}
|
||||||
|
return sentences[presentation.key]
|
||||||
|
|
||||||
|
|
||||||
def validation_result_box(value: str | None, *, compact: bool = False) -> str:
|
def validation_result_box(value: str | None, *, compact: bool = False) -> str:
|
||||||
presentation = validation_result_presentation(value)
|
presentation = validation_result_presentation(value)
|
||||||
size_class = "result-box--compact" if compact else "result-box--cover"
|
size_class = "result-box--compact" if compact else "result-box--cover"
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,31 @@ h1 {
|
||||||
page-break-inside: avoid;
|
page-break-inside: avoid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cover-result-text {
|
||||||
|
border-top: .25mm solid #DCE3E3;
|
||||||
|
break-inside: avoid;
|
||||||
|
margin: 2mm 0 0 0;
|
||||||
|
page-break-inside: avoid;
|
||||||
|
padding-top: 2.2mm;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover-result-text h2 {
|
||||||
|
border: 0;
|
||||||
|
color: #4F6A74;
|
||||||
|
font-size: 10pt;
|
||||||
|
letter-spacing: .04em;
|
||||||
|
margin: 0 0 1mm 0;
|
||||||
|
padding: 0;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover-result-text p {
|
||||||
|
color: #2E3B40;
|
||||||
|
font-size: 10.5pt;
|
||||||
|
font-weight: 700;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.result-box {
|
.result-box {
|
||||||
border: .65mm solid #8A9498;
|
border: .65mm solid #8A9498;
|
||||||
border-radius: 1.5mm;
|
border-radius: 1.5mm;
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -917,23 +917,52 @@ def test_orion_result_boxes_render_on_cover_summary_and_results(tmp_path):
|
||||||
|
|
||||||
html = OrionReportService(db, tmp_path).render_html(validation.id)
|
html = OrionReportService(db, tmp_path).render_html(validation.id)
|
||||||
|
|
||||||
assert html.count("VALIDIERUNGSERGEBNIS") >= 3
|
assert html.count("VALIDIERUNGSERGEBNIS") >= 2
|
||||||
assert "BESTANDEN MIT AUFLAGEN" in html
|
assert 'class="result-box result-box--cover' not in html
|
||||||
|
assert html.count('class="result-box result-box--compact') >= 2
|
||||||
|
assert "Ergebnis der Validierung" in html
|
||||||
|
assert "Die technische Validierung wurde mit Auflagen bestanden." in html
|
||||||
|
assert "BESTANDEN MIT AUFLAGEN" not in html
|
||||||
assert "Bestanden mit Auflagen" in html
|
assert "Bestanden mit Auflagen" in html
|
||||||
assert 'class="cover-closing"' in html
|
assert 'class="cover-closing"' in html
|
||||||
|
assert 'class="cover-result-text"' in html
|
||||||
assert 'class="signature-block"' in html
|
assert 'class="signature-block"' in html
|
||||||
assert "Unterschrift technische Validierung" in html
|
assert "Unterschrift technische Validierung" in html
|
||||||
assert "Unterschrift Auftraggeber" not in html
|
assert "Unterschrift Auftraggeber" not in html
|
||||||
assert html.index('id="cover"') < html.index("BESTANDEN MIT AUFLAGEN")
|
|
||||||
assert html.index('id="summary"') < html.index("Bestanden mit Auflagen")
|
assert html.index('id="summary"') < html.index("Bestanden mit Auflagen")
|
||||||
assert html.index('id="results"') < html.rindex("Bestanden mit Auflagen")
|
assert html.index('id="results"') < html.rindex("Bestanden mit Auflagen")
|
||||||
|
|
||||||
|
|
||||||
|
def test_orion_cover_result_text_for_supported_statuses(tmp_path):
|
||||||
|
expected = {
|
||||||
|
"BESTANDEN": "Die technische Validierung wurde erfolgreich bestanden.",
|
||||||
|
"BESTANDEN_MIT_AUFLAGEN": "Die technische Validierung wurde mit Auflagen bestanden.",
|
||||||
|
"NICHT_BESTANDEN": "Die technische Validierung wurde nicht bestanden.",
|
||||||
|
}
|
||||||
|
|
||||||
|
for value, sentence in expected.items():
|
||||||
|
db = session()
|
||||||
|
customer, location, device = seed(db)
|
||||||
|
validation = valid_validation(customer, location, device)
|
||||||
|
validation.report_number = f"VAL-{value}"
|
||||||
|
validation.result = value
|
||||||
|
db.add(validation)
|
||||||
|
db.flush()
|
||||||
|
|
||||||
|
html = OrionReportService(db, tmp_path / value).render_html(validation.id)
|
||||||
|
|
||||||
|
assert "Ergebnis der Validierung" in html
|
||||||
|
assert sentence in html
|
||||||
|
assert 'class="result-box result-box--cover' not in html
|
||||||
|
assert html.count('class="result-box result-box--compact') >= 2
|
||||||
|
|
||||||
|
|
||||||
def test_orion_result_box_css_prevents_page_breaks():
|
def test_orion_result_box_css_prevents_page_breaks():
|
||||||
css = Path("app/modules/orion/templates/report.css").read_text(encoding="utf-8")
|
css = Path("app/modules/orion/templates/report.css").read_text(encoding="utf-8")
|
||||||
|
|
||||||
assert ".result-box" in css
|
assert ".result-box" in css
|
||||||
assert ".cover-closing" in css
|
assert ".cover-closing" in css
|
||||||
|
assert ".cover-result-text" in css
|
||||||
assert ".signature-block" in css
|
assert ".signature-block" in css
|
||||||
assert "break-inside: avoid" in css
|
assert "break-inside: avoid" in css
|
||||||
assert "page-break-inside: avoid" in css
|
assert "page-break-inside: avoid" in css
|
||||||
|
|
@ -1116,8 +1145,8 @@ def test_orion_pdf_first_page_is_cover_not_blank(tmp_path):
|
||||||
|
|
||||||
assert "PRÜFBERICHTZURVALIDIERUNG" in normalized_text
|
assert "PRÜFBERICHTZURVALIDIERUNG" in normalized_text
|
||||||
assert "FUNKTIONS-UNDLEISTUNGSQUALIFIKATION" in normalized_text
|
assert "FUNKTIONS-UNDLEISTUNGSQUALIFIKATION" in normalized_text
|
||||||
assert "VALIDIERUNGSERGEBNIS" in normalized_text
|
assert "ERGEBNISDERVALIDIERUNG" in normalized_text
|
||||||
assert "BESTANDEN" in normalized_text
|
assert "DIETECHNISCHEVALIDIERUNGWURDEERFOLGREICHBESTANDEN" in normalized_text
|
||||||
|
|
||||||
|
|
||||||
def test_orion_bookmark_labels_are_created_from_central_sections(tmp_path):
|
def test_orion_bookmark_labels_are_created_from_central_sections(tmp_path):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue