Skip to content

Commit

Permalink
Voeg template voor voortgang voorfase producten toe.
Browse files Browse the repository at this point in the history
Closes #760.
  • Loading branch information
fniessink committed Nov 27, 2024
1 parent ba0adca commit 875b3ac
Show file tree
Hide file tree
Showing 26 changed files with 145 additions and 80 deletions.
107 changes: 54 additions & 53 deletions Content/Templates/PvA-Voorfase/Template-Inhoud.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Content/Wijzigingsgeschiedenis.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Versie 4.1.0, nog niet gereleased

## Template Plan van Aanpak Voorfase

* Genereer de tabel met voorfaseproducten ook in Excel-formaat.

# Versie 4.0.2, 26 november 2024

## Alle templates
Expand Down
9 changes: 8 additions & 1 deletion DocumentDefinitions/plan-van-aanpak-voorfase.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
"docs/$VERSIE$"
],
"ReferenceFile": "DocumentDefinitions/reference-ictu.docx"
},
"xlsx": {
"BuilderClass": "VoorfaseProductenXlsxBuilder",
"OutputFile": "ICTU-Template-Plan-van-Aanpak-Voorfase-Producten.xlsx",
"OutputPaths": [
"docs/$VERSIE$"
]
}
},
"VariablesFiles": [
"DocumentDefinitions/Shared/variables.json"
]
}
}
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ <h2 class="toc">Onderhanden werk</h2>
<li><a href="wip/ICTU-Kwaliteitsaanpak-Samenvatting.html">ICTU Kwaliteitsaanpak samenvatting in HTML-formaat</a></li>
<li><a href="wip/ICTU-Kwaliteitsaanpak-Checklist.xlsx">ICTU Kwaliteitsaanpak self-assessment Excel-spreadsheet</a></li>
<li><a href="wip/ICTU-Template-Plan-van-Aanpak-Voorfase.docx">ICTU template plan van aanpak voorfase</a></li>
<li><a href="wip/ICTU-Template-Plan-van-Aanpak-Voorfase-Producten.xlsx">ICTU template plan van aanpak voorfase producten</a></li>
<li><a href="wip/ICTU-Template-Plan-van-Aanpak-Realisatiefase.docx">ICTU template plan van aanpak realisatiefase</a></li>
<li><a href="wip/ICTU-Template-Compacte-Voorfase.docx">ICTU template compacte voorfase</a></li>
<li><a href="wip/ICTU-Template-Detailtestplan.docx">ICTU template detailtestplan</a></li>
Expand Down
Binary file modified docs/wip/ICTU-Kwaliteitsaanpak-Checklist.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/wip/ICTU-Kwaliteitsaanpak-Samenvatting.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/wip/ICTU-Kwaliteitsaanpak-Wijzigingsgeschiedenis.html

Large diffs are not rendered by default.

Binary file modified docs/wip/ICTU-Kwaliteitsaanpak.docx
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/wip/ICTU-Kwaliteitsaanpak.html

Large diffs are not rendered by default.

Binary file modified docs/wip/ICTU-Kwaliteitsaanpak.pptx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Compacte-Voorfase.docx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Detailtestplan-Softwarerealisatie.docx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Generiek.docx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Globaal-Functioneel-Ontwerp.docx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Inwerkplan-Kwaliteitsmanager.docx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Kwaliteitsplan.docx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Plan-van-Aanpak-Realisatiefase.docx
Binary file not shown.
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Plan-van-Aanpak-Voorfase.docx
Binary file not shown.
Binary file modified docs/wip/ICTU-Template-Software-architectuurdocument.docx
Binary file not shown.
Binary file modified docs/wip/Neutraal-Template-Generiek.docx
Binary file not shown.
Binary file modified docs/wip/Neutraal-Template-Infrastructuurarchitectuur.docx
Binary file not shown.
Binary file modified docs/wip/Neutraal-Template-Mastertestplan.docx
Binary file not shown.
Binary file modified docs/wip/Neutraal-Template-Niet-Functionele-Eisen.docx
Binary file not shown.
Binary file added docs/wip/~$TU-Template-Plan-van-Aanpak-Voorfase.docx
Binary file not shown.
96 changes: 73 additions & 23 deletions src/builder/xlsx_builder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Self-assessment XLSX-spreadsheet builder."""
"""XLSX-spreadsheet builder."""

import datetime
import pathlib
import re
from typing import Dict, List, Optional
import string

import xlsxwriter

Expand All @@ -12,7 +12,70 @@
from .builder import Builder


class SelfAssessmentXlsxBuilder(Builder):
class XlsxBuilder(Builder):
"""Base class for XLSX builders."""

def __init__(self, filename: pathlib.Path) -> None:
super().__init__(filename)
filename.unlink(missing_ok=True)
self.workbook = xlsxwriter.Workbook(filename)
self.formats = self.create_formats(self.workbook)

def end_document(self) -> None:
self.workbook.close()

def create_formats(self, workbook: xlsxwriter.Workbook) -> dict[str, xlsxwriter.format.Format]:
return {
"header": workbook.add_format(
{"text_wrap": True, "font_size": 14, "bold": True, "bg_color": "#B3D6C9"}
),
}

def set_column_width(self, sheet, column: int, width: int) -> None:
"""Set the width of the column in the sheet."""
sheet.set_column(f"{string.ascii_uppercase[column]}:{string.ascii_uppercase[column]}", width)


class VoorfaseProductenXlsxBuilder(XlsxBuilder):
"""Voorfase producten builder."""

COLUMN_WIDTH = {0: 50, 1: 40, 2: 40, 3: 40}
STATUS_COLUMN_WIDTH = 20
NR_WEEKS = 7

def __init__(self, filename: pathlib.Path) -> None:
super().__init__(filename)
self.sheet = self.workbook.add_worksheet("Voorfase-producten")
self.in_product_section = False
self.cell_contents = []
self.sheet.freeze_panes(1, 1)

def text(self, tag: str, text: str, attributes: TreeBuilderAttributes) -> None:
if text == "Producten" and tag == xmltags.HEADING:
self.in_product_section = True
if self.in_product_section and self.in_element(xmltags.TABLE_CELL):
self.cell_contents.append(text)

def end_element(self, tag: str, attributes: TreeBuilderAttributes) -> None:
super().end_element(tag, attributes)
if tag == xmltags.SECTION:
self.in_product_section = False
if self.in_product_section:
if tag == xmltags.TABLE_CELL:
row = int(attributes[xmltags.TABLE_CELL_ROW])
column = int(attributes[xmltags.TABLE_CELL_COLUMN])
format = self.formats["header"] if self.in_element(xmltags.TABLE_HEADER_ROW) or column == 0 else None
self.set_column_width(self.sheet, column, self.COLUMN_WIDTH[column])
self.sheet.write(row, column, " ".join(self.cell_contents), format)
self.cell_contents = []
if tag == xmltags.TABLE:
for week in range(self.NR_WEEKS):
column = int(attributes[xmltags.TABLE_COLUMNS]) + week
self.sheet.write(0, column, f"Status week {week + 1}", self.formats["header"])
self.set_column_width(self.sheet, column, self.STATUS_COLUMN_WIDTH)


class SelfAssessmentXlsxBuilder(XlsxBuilder):
"""Self-assessment builder."""

MEASURE_ID_COLUMN, MEASURE_COLUMN, STATUS_COLUMN, EXPLANATION_COLUMN = range(4)
Expand All @@ -21,19 +84,13 @@ class SelfAssessmentXlsxBuilder(Builder):

def __init__(self, filename: pathlib.Path) -> None:
super().__init__(filename)
filename.unlink(missing_ok=True)
self.workbook = xlsxwriter.Workbook(filename)
self.formats = self.__create_formats(self.workbook)
self.checklist = self.workbook.add_worksheet("Self-assessment checklist")
self.row = self.measure_row = self.MEASURE_START_ROW
self.last_level_1_section_heading = ""
self.measure_id: Optional[str] = None
self.measure_text: List[str] = []
self.measure_id: str | None = None
self.measure_text: list[str] = []

@staticmethod
def __create_formats(
workbook: xlsxwriter.Workbook,
) -> Dict[str, xlsxwriter.format.Format]:
def create_formats(self, workbook: xlsxwriter.Workbook) -> dict[str, xlsxwriter.format.Format]:
"""Create the formats."""
measure_format_options = {
"bg_color": "#BCD2EE",
Expand All @@ -42,14 +99,6 @@ def __create_formats(
}
status_format_options = {"bg_color": "#FED32D", "text_wrap": True}
return {
"header": workbook.add_format(
{
"text_wrap": True,
"font_size": 14,
"bold": True,
"bg_color": "#B3D6C9",
}
),
"instructions": workbook.add_format({"text_wrap": True, "font_size": 13, "bg_color": "#B3D6C9"}),
"measure": workbook.add_format(measure_format_options),
"submeasure": workbook.add_format({"align": "vjustify", "indent": 1, **measure_format_options}),
Expand All @@ -60,6 +109,7 @@ def __create_formats(
"voldoet deels": workbook.add_format({"fg_color": "#894503", "bg_color": "#FEE88A"}),
"voldoet niet": workbook.add_format({"fg_color": "#880009", "bg_color": "#FEB8C3"}),
"niet van toepassing": workbook.add_format({"fg_color": "#6D6D6D", "bg_color": "#EFEFEF"}),
**super().create_formats(workbook),
}

def start_element(self, tag: str, attributes: TreeBuilderAttributes) -> None:
Expand Down Expand Up @@ -189,7 +239,7 @@ def end_element(self, tag: str, attributes: TreeBuilderAttributes) -> None:

def end_document(self) -> None:
self.__create_action_list()
self.workbook.close()
super().end_document()

def __create_checklist(self, version: str) -> None:
self.checklist.merge_range(
Expand Down Expand Up @@ -233,7 +283,7 @@ def __create_checklist(self, version: str) -> None:
]
):
self.checklist.write(self.HEADER_ROW, column, header, self.formats["header"])
self.checklist.set_column(f"{'ABCD'[column]}:{'ABCD'[column]}", width)
self.set_column_width(self.checklist, column, width)

def __finish_checklist(self) -> None:
"""Wrap up the checklist."""
Expand Down Expand Up @@ -274,7 +324,7 @@ def __create_action_list(self) -> None:
action_list.set_row(1, 30)
for column, (header, width) in enumerate([("Datum", 12), ("Actie", 70), ("Status", 20), ("Toelichting", 70)]):
action_list.write(1, column, header, self.formats["header"])
action_list.set_column(f"{'ABCD'[column]}:{'ABCD'[column]}", width)
self.set_column_width(action_list, column, width)

def __in_appendix(self) -> bool:
"""Return whether the current section is in an appendix."""
Expand Down

0 comments on commit 875b3ac

Please sign in to comment.