diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index 7f2fbc91a..2bfa117ea 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -185,9 +185,9 @@ paths: schema: $ref: "#/components/schemas/ProcessModelCategory" - /process-groups/{process_group_id}: + /process-groups/{modified_process_group_id}: parameters: - - name: process_group_id + - name: modified_process_group_id in: path required: true description: The unique id of an existing process group. diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py index 381f8f63b..9efc8cf5e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py @@ -27,6 +27,9 @@ class ProcessGroup: process_models: list[ProcessModelInfo] = field( default_factory=list[ProcessModelInfo] ) + process_groups: list[ProcessGroup] = field( + default_factory=list['ProcessGroup'] + ) def __post_init__(self) -> None: """__post_init__.""" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index 1081494b3..68cabd8e8 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -153,13 +153,14 @@ def process_group_add(body: dict) -> flask.wrappers.Response: return make_response(jsonify(process_group), 201) -def process_group_delete(process_group_id: str) -> flask.wrappers.Response: +def process_group_delete(modified_process_group_id: str) -> flask.wrappers.Response: """Process_group_delete.""" + process_group_id = un_modify_modified_process_model_id(modified_process_group_id) ProcessModelService().process_group_delete(process_group_id) return Response(json.dumps({"ok": True}), status=200, mimetype="application/json") -def process_group_update(process_group_id: str, body: dict) -> flask.wrappers.Response: +def process_group_update(modified_process_group_id: str, body: dict) -> flask.wrappers.Response: """Process Group Update.""" body_include_list = ["display_name", "description"] body_filtered = { @@ -168,6 +169,7 @@ def process_group_update(process_group_id: str, body: dict) -> flask.wrappers.Re if include_item in body } + process_group_id = un_modify_modified_process_model_id(modified_process_group_id) process_group = ProcessGroup(id=process_group_id, **body_filtered) ProcessModelService().update_process_group(process_group) return make_response(jsonify(process_group), 200) @@ -196,9 +198,10 @@ def process_groups_list(page: int = 1, per_page: int = 100) -> flask.wrappers.Re def process_group_show( - process_group_id: str, + modified_process_group_id: str, ) -> Any: """Process_group_show.""" + process_group_id = un_modify_modified_process_model_id(modified_process_group_id) try: process_group = ProcessModelService().get_process_group(process_group_id) except ProcessEntityNotFoundError as exception: @@ -224,10 +227,13 @@ def process_model_add( status_code=400, ) + modified_process_model_id = process_model_info.id + unmodified_process_model_id = un_modify_modified_process_model_id(modified_process_model_id) + process_model_info.id = unmodified_process_model_id process_group_id, _ = os.path.split(process_model_info.id) process_model_service = ProcessModelService() process_group = process_model_service.get_process_group( - process_group_id + un_modify_modified_process_model_id(process_group_id) ) if process_group is None: raise ApiError( diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/user.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/user.py index 5bf4e48bc..4a2f19b11 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/user.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/user.py @@ -125,7 +125,7 @@ def verify_token( # no user_info else: raise ApiError( - error_code="no_user_info", message="Cannot retrieve user info" + error_code="no_user_info", message="Cannot retrieve user info", status_code=401 ) else: diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py index b91459e47..aaa8ded6f 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py @@ -168,6 +168,7 @@ class ProcessModelService(FileSystemService): def get_process_group(self, process_group_id: str) -> ProcessGroup: """Look for a given process_group, and return it.""" if os.path.exists(FileSystemService.root_path()): + process_group_path = os.path.join(FileSystemService.root_path(), process_group_id) if self.is_group(process_group_path): return self.__scan_process_group(process_group_path) @@ -264,12 +265,17 @@ class ProcessModelService(FileSystemService): json.dump(self.GROUP_SCHEMA.dump(process_group), wf_json, indent=4) with os.scandir(dir_path) as nested_items: process_group.process_models = [] + process_group.process_groups = [] for nested_item in nested_items: if nested_item.is_dir(): # TODO: check whether this is a group or model if self.is_group(nested_item.path): # This is a nested group - ... + process_group.process_groups.append( + self.__scan_process_group( + nested_item.path + ) + ) elif self.is_model(nested_item.path): process_group.process_models.append( self.__scan_spec( @@ -277,6 +283,7 @@ class ProcessModelService(FileSystemService): ) ) process_group.process_models.sort() + # process_group.process_groups.sort() return process_group def __scan_spec(