Skip to content

Commit

Permalink
Merge pull request #705 from euphorie/scrum-1297-short-report-options
Browse files Browse the repository at this point in the history
Make short report configurable
  • Loading branch information
reinhardt authored Feb 28, 2024
2 parents db8b2f4 + 1f8894f commit 7a53a91
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
16.0.2 (unreleased)
-------------------

- Short report can be activated per country
Ref: scrum-1297
[reinhardt]

- Use Plone 6.0.10


Expand Down
27 changes: 26 additions & 1 deletion src/euphorie/client/browser/templates/report_landing.pt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,38 @@
reports view/default_reports;
"
>
<div class="download-block"
tal:condition="python:'report_compact' in reports"
>
<div class="download-block-header">
<h2 class=""
i18n:translate="label_report"
>Compact</h2>
<a class="default pat-button download rtf icon-download piwik_download"
href="${context/absolute_url}/@@oira-report-short.docx"
>
<tal:trans i18n:translate="button_download">Download</tal:trans></a>
</div>
<div class="download-block-body pat-rich">
<ul>
<li><tal:i18n i18n:translate="label_format">Format</tal:i18n>: Word (.docx)</li>
<li i18n:translate="">Contains: Concise information and input provided by you throughout the risk assessment process.</li>
</ul>

<h4><tal:span i18n:translate="use_it_to_compact_report">Use it to</tal:span>:</h4>
<ul>
<li i18n:translate="">Provide a concise overview over your current status for internal use.</li>
</ul>
</div>
</div>

<div class="download-block"
tal:condition="python:'report_full' in reports"
>
<div class="download-block-header">
<h2 class=""
i18n:translate="label_report"
>Report</h2>
>Full Report</h2>
<a class="default pat-button download rtf icon-download piwik_download"
href="${context/absolute_url}/@@oira-report.docx"
>
Expand Down
34 changes: 30 additions & 4 deletions src/euphorie/client/docx/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")

Expand Down Expand Up @@ -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 = ""
Expand Down
38 changes: 37 additions & 1 deletion src/euphorie/content/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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=_(
Expand Down

0 comments on commit 7a53a91

Please sign in to comment.