From 8ab251bfa09eaae9397bccff0b4317e66871c4ba Mon Sep 17 00:00:00 2001 From: Manuel Reinhardt Date: Tue, 20 Feb 2024 14:26:30 +0100 Subject: [PATCH] Make short report configurable syslabcom/scrum#1297 --- docs/changes.rst | 4 +- .../browser/templates/report_landing.pt | 27 ++++++++++++- src/euphorie/client/docx/compiler.py | 34 +++++++++++++++-- src/euphorie/content/country.py | 38 ++++++++++++++++++- 4 files changed, 96 insertions(+), 7 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 8c6b1d52b5..73ec420a4b 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -4,7 +4,9 @@ Changelog 16.0.2 (unreleased) ------------------- -- Nothing changed yet. +- Short report can be activated per country + Ref: scrum-1297 + [reinhardt] 16.0.1 (2024-02-20) diff --git a/src/euphorie/client/browser/templates/report_landing.pt b/src/euphorie/client/browser/templates/report_landing.pt index 43dc90a89b..3879b6d712 100644 --- a/src/euphorie/client/browser/templates/report_landing.pt +++ b/src/euphorie/client/browser/templates/report_landing.pt @@ -38,13 +38,38 @@ reports view/default_reports; " > +
+
+

Compact

+ + Download +
+
+
    +
  • Format: Word (.docx)
  • +
  • Contains: Concise information and input provided by you throughout the risk assessment process.
  • +
+ +

Use it to:

+
    +
  • Provide a concise overview over your current status for internal use.
  • +
+
+
+

Report

+ >Full Report diff --git a/src/euphorie/client/docx/compiler.py b/src/euphorie/client/docx/compiler.py index ad3dedbcf2..7d80993df0 100644 --- a/src/euphorie/client/docx/compiler.py +++ b/src/euphorie/client/docx/compiler.py @@ -1019,6 +1019,28 @@ class DocxCompilerShort(DocxCompilerFullTable): justifiable_map = {"yes": "✅", "no": "❌", "postponed": "?"} justifiable_font = {"postponed": {"color": RGBColor(0xCC, 0xCC, 0x0), "bold": True}} + @property + @memoize + def options(self): + country = self.webhelpers.content_country_obj + return country.compact_report_options + + @property + def is_show_description_of_risks(self): + return "description_of_risks" in self.options + + @property + def is_show_comments(self): + return "comments" in self.options + + @property + def is_show_description_of_measures(self): + return "description_of_measures" in self.options + + @property + def is_show_measure_responsible_date(self): + return "measure_responsible_date" in self.options + def set_answer_font(self, answer, cell): font = self.justifiable_font.get(answer) if font: @@ -1039,9 +1061,12 @@ def set_cell_risk(self, cell, risk): title, descripton, comment, measures in place """ self.set_cell_risk_title(cell, risk) - self.set_cell_risk_description(cell, risk) - self.set_cell_risk_measures(cell, risk) - self.set_cell_risk_comment(cell, risk) + if self.is_show_description_of_risks: + self.set_cell_risk_description(cell, risk) + if self.is_show_description_of_measures: + self.set_cell_risk_measures(cell, risk) + if self.is_show_comments: + self.set_cell_risk_comment(cell, risk) cell.add_paragraph(style="Risk Normal") @@ -1069,7 +1094,8 @@ def set_cell_actions(self, cell, risk): if idx != 0: cell.add_paragraph() self.set_cell_action_text(cell, action) - self.set_cell_action_responsible(cell, action) + if self.is_show_measure_responsible_date: + self.set_cell_action_responsible(cell, action) def set_cell_action_responsible(self, cell, action): text_responsible = "" diff --git a/src/euphorie/content/country.py b/src/euphorie/content/country.py index 715b0f7341..208b024da9 100644 --- a/src/euphorie/content/country.py +++ b/src/euphorie/content/country.py @@ -12,6 +12,7 @@ from plone.autoform import directives from plone.dexterity.content import Container from plone.supermodel import model +from plonetheme.nuplone.z3cform.directives import depends from z3c.form.browser.checkbox import CheckBoxFieldWidget from zope import schema from zope.interface import implementer @@ -75,11 +76,14 @@ class ICountry(model.Schema, IBasic): title=_("label__default_reports", "Available reports"), description=_( "help__default_reports", - "Define, which reports are offered to the user on the Report page.", + "Define which reports are offered to the user on the Report page.", ), value_type=schema.Choice( vocabulary=SimpleVocabulary( [ + SimpleTerm( + "report_compact", title=_("Compact report (Word document)") + ), SimpleTerm("report_full", title=_("Full report (Word document)")), SimpleTerm( "report_action_plan", @@ -99,6 +103,38 @@ class ICountry(model.Schema, IBasic): required=False, ) + depends("compact_report_options", "default_reports", "==", "report_compact") + directives.widget(compact_report_options=CheckBoxFieldWidget) + compact_report_options = schema.List( + title=_("label_compact_report_options", "Compact report options"), + description=_( + "help_compact_report_options", + "Select which optional elements are used in the compact report", + ), + value_type=schema.Choice( + vocabulary=SimpleVocabulary( + [ + SimpleTerm("description_of_risks", title=_("Description of risks")), + SimpleTerm("comments", title=_("Comments")), + SimpleTerm( + "description_of_measures", title=_("Description of measures") + ), + SimpleTerm( + "measure_responsible_date", + title=_("Measure responsible and date"), + ), + ] + ) + ), + default=[ + "description_of_risks", + "comments", + "description_of_measures", + "measure_responsible_date", + ], + required=False, + ) + enable_web_training = schema.Bool( title=_("label_enable_web_training", default="Enable Web Based Training?"), description=_(