Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short report: Mark postponed risks #693

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Changelog
- Update nl translations.
[ale-rt, angeldasangel]

- Short report: Mark postponed risks
Ref: scrum-1852
[reinhardt]

- Changed PDF generation engine to weasyprint
Ref: scrum-732
[reinhardt]
Expand Down
21 changes: 17 additions & 4 deletions src/euphorie/client/docx/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml import OxmlElement
from docx.oxml.ns import qn
from docx.shared import RGBColor
from euphorie.client import MessageFactory as _
from euphorie.client.docx.html import HtmlToWord
from euphorie.content.solution import ISolution
Expand Down Expand Up @@ -795,6 +796,9 @@ def merge_module_rows(self, row_module, row_risk):
for idx, cell in enumerate(row_risk.cells[1:]):
self.set_cell_border(cell, settings=LEFT_RIGHT_BORDERS)

def set_answer_font(self, answer, cell):
"""Overridden in subclasses"""

def set_modules_rows(self, data):
"""This takes a list of modules and creates the rows for them."""
modules = data.get("modules", [])
Expand All @@ -815,6 +819,8 @@ def set_modules_rows(self, data):
count = 0
for risk in risks:
answer = risk.get("justifiable", "")
if not answer and risk.get("postponed", False):
answer = "postponed"
# In case our report type defines this:
# Omit risk if the user has not answered it
if self.only_anwered_risks:
Expand All @@ -832,9 +838,9 @@ def set_modules_rows(self, data):
count += 1
self.set_cell_risk(row_risk.cells[self.risk_description_col], risk)
if self.risk_answer_col is not None:
row_risk.cells[self.risk_answer_col].text = (
self.justifiable_map.get(answer) or ""
)
cell = row_risk.cells[self.risk_answer_col]
cell.text = self.justifiable_map.get(answer) or ""
self.set_answer_font(answer, cell)
self.set_cell_actions(row_risk.cells[self.risk_measures_col], risk)

if count:
Expand Down Expand Up @@ -1010,7 +1016,14 @@ def compile(self, data):
class DocxCompilerShort(DocxCompilerFullTable):
_base_filename = "oira_short.docx"

justifiable_map = {"yes": "✅", "no": "❌", None: "⧁"}
justifiable_map = {"yes": "✅", "no": "❌", "postponed": "?", None: "⧁"}
justifiable_font = {"postponed": {"color": RGBColor(0xCC, 0xCC, 0x0), "bold": True}}

def set_answer_font(self, answer, cell):
font = self.justifiable_font.get(answer)
if font:
cell.paragraphs[0].runs[0].font.color.rgb = font.get("color")
cell.paragraphs[0].runs[0].font.bold = font.get("bold", False)

def set_cell_risk_title(self, cell, risk):
paragraph = cell.paragraphs[0]
Expand Down
1 change: 1 addition & 0 deletions src/euphorie/client/docx/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def get_risks_for(self, sql_module):
"measures": measures,
"epilogue": "",
"justifiable": sql_risk.identification,
"postponed": sql_risk.postponed,
"number": sql_risk.number,
"priority": sql_risk.priority,
}
Expand Down
Loading