Add task administration upgrade with duplicate merge and task tools
This commit is contained in:
@@ -26,6 +26,7 @@ _HEADERS = [
|
||||
"response_type",
|
||||
"evidence_required",
|
||||
"remarks_required_if_no",
|
||||
"task_tool_code",
|
||||
"is_aqmm_task",
|
||||
"aqmm_mandatory",
|
||||
"aqmm_evidence_required",
|
||||
@@ -50,6 +51,7 @@ _IMPORT_HEADERS = [
|
||||
"response_type",
|
||||
"evidence_required",
|
||||
"remarks_required_if_no",
|
||||
"task_tool_code",
|
||||
"is_aqmm_task",
|
||||
"aqmm_mandatory",
|
||||
"aqmm_evidence_required",
|
||||
@@ -94,11 +96,13 @@ def _style_sheet(ws, widths: dict[int, int]) -> None:
|
||||
cell.alignment = Alignment(vertical="top", wrap_text=True)
|
||||
|
||||
|
||||
def _query_active_services(db: Session) -> list[ServiceCatalogue]:
|
||||
def _query_active_services(db: Session, *, catalogue_id: int | None = None) -> list[ServiceCatalogue]:
|
||||
stmt = select(ServiceCatalogue).where(ServiceCatalogue.is_active.is_(True))
|
||||
if catalogue_id is not None:
|
||||
stmt = stmt.where(ServiceCatalogue.id == catalogue_id)
|
||||
return list(
|
||||
db.execute(
|
||||
select(ServiceCatalogue)
|
||||
.where(ServiceCatalogue.is_active.is_(True))
|
||||
stmt
|
||||
.options(
|
||||
selectinload(ServiceCatalogue.service_category),
|
||||
selectinload(ServiceCatalogue.default_task_templates),
|
||||
@@ -112,8 +116,8 @@ def _query_active_services(db: Session) -> list[ServiceCatalogue]:
|
||||
)
|
||||
|
||||
|
||||
def build_default_tasks_export(db: Session) -> bytes:
|
||||
services = _query_active_services(db)
|
||||
def build_default_tasks_export(db: Session, *, catalogue_id: int | None = None) -> bytes:
|
||||
services = _query_active_services(db, catalogue_id=catalogue_id)
|
||||
|
||||
workbook = Workbook()
|
||||
all_tasks_ws = workbook.active
|
||||
@@ -169,6 +173,7 @@ def build_default_tasks_export(db: Session) -> bytes:
|
||||
task.response_type or "NONE",
|
||||
_yes_no(task.evidence_required),
|
||||
_yes_no(task.remarks_required_if_no),
|
||||
getattr(task, "task_tool_code", "NONE") or "NONE",
|
||||
_yes_no(task.is_aqmm_task),
|
||||
_yes_no(task.aqmm_mandatory),
|
||||
_yes_no(task.aqmm_evidence_required),
|
||||
@@ -192,6 +197,7 @@ def build_default_tasks_export(db: Session) -> bytes:
|
||||
task.response_type or "NONE",
|
||||
_yes_no(task.evidence_required),
|
||||
_yes_no(task.remarks_required_if_no),
|
||||
getattr(task, "task_tool_code", "NONE") or "NONE",
|
||||
_yes_no(task.is_aqmm_task),
|
||||
_yes_no(task.aqmm_mandatory),
|
||||
_yes_no(task.aqmm_evidence_required),
|
||||
|
||||
Reference in New Issue
Block a user