Accept report_identifier
This commit is contained in:
parent
052b015ad6
commit
0230ea914b
|
@ -79,6 +79,7 @@ class ProcessInstanceReportModel(SpiffworkflowBaseDBModel):
|
|||
identifier=identifier, created_by_id=user.id
|
||||
).first()
|
||||
|
||||
# TODO replace with system report that is loaded on launch (or similar)
|
||||
if process_instance_report is None:
|
||||
report_metadata = {
|
||||
"columns": [
|
||||
|
|
|
@ -739,7 +739,7 @@ def process_instance_list(
|
|||
report_identifier: Optional[str] = None
|
||||
) -> flask.wrappers.Response:
|
||||
"""Process_instance_list."""
|
||||
process_instance_report = ProcessInstanceReportModel.default_report(g.user)
|
||||
process_instance_report = ProcessInstanceReportService.report_with_identifier(g.user, report_identifier)
|
||||
|
||||
if user_filter:
|
||||
report_filter = ProcessInstanceReportFilter(
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import Optional
|
|||
from spiffworkflow_backend.models.process_instance_report import (
|
||||
ProcessInstanceReportModel,
|
||||
)
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -41,6 +42,63 @@ class ProcessInstanceReportFilter:
|
|||
class ProcessInstanceReportService:
|
||||
"""ProcessInstanceReportService."""
|
||||
|
||||
@classmethod
|
||||
def report_with_identifier(
|
||||
cls,
|
||||
user: UserModel,
|
||||
report_identifier: Optional[str] = None
|
||||
) -> ProcessInstanceReportModel:
|
||||
if report_identifier is None:
|
||||
return ProcessInstanceReportModel.default_report(user)
|
||||
|
||||
# TODO replace with system reports that are loaded on launch (or similar)
|
||||
temp_system_metdata_map = {
|
||||
"system_report_instances_initiated_by_me": {
|
||||
"columns": [
|
||||
{"Header": "id", "accessor": "id"},
|
||||
{
|
||||
"Header": "process_model_identifier",
|
||||
"accessor": "process_model_identifier",
|
||||
},
|
||||
{"Header": "start_in_seconds", "accessor": "start_in_seconds"},
|
||||
{"Header": "end_in_seconds", "accessor": "end_in_seconds"},
|
||||
{"Header": "status", "accessor": "status"},
|
||||
],
|
||||
},
|
||||
"system_report_instances_with_tasks_completed_by_me": {
|
||||
"columns": [
|
||||
{"Header": "start_in_seconds", "accessor": "start_in_seconds"},
|
||||
{"Header": "end_in_seconds", "accessor": "end_in_seconds"},
|
||||
{"Header": "status", "accessor": "status"},
|
||||
{"Header": "id", "accessor": "id"},
|
||||
{
|
||||
"Header": "process_model_identifier",
|
||||
"accessor": "process_model_identifier",
|
||||
},
|
||||
],
|
||||
},
|
||||
"system_report_instances_with_tasks_completed_by_my_groups": {
|
||||
"columns": [
|
||||
{
|
||||
"Header": "process_model_identifier",
|
||||
"accessor": "process_model_identifier",
|
||||
},
|
||||
{"Header": "start_in_seconds", "accessor": "start_in_seconds"},
|
||||
{"Header": "end_in_seconds", "accessor": "end_in_seconds"},
|
||||
{"Header": "status", "accessor": "status"},
|
||||
{"Header": "id", "accessor": "id"},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
process_instance_report = cls(
|
||||
identifier=identifier,
|
||||
created_by_id=user.id,
|
||||
report_metadata=temp_system_metadata_map[report_identifier],
|
||||
)
|
||||
|
||||
return process_instance_report
|
||||
|
||||
@classmethod
|
||||
def filter_by_to_dict(
|
||||
cls, process_instance_report: ProcessInstanceReportModel
|
||||
|
|
Loading…
Reference in New Issue