diff --git a/docker-compose.yml b/docker-compose.yml index 12a0936fd..1cbe9dcb7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,6 +62,7 @@ services: - SPIFFWORKFLOW_BACKEND_DATABASE_URI=mysql+mysqlconnector://root:${SPIFFWORKFLOW_BACKEND_MYSQL_ROOT_DATABASE:-my-secret-pw}@localhost:7003/${SPIFFWORKFLOW_BACKEND_DATABASE_NAME:-spiffworkflow_backend_development} - BPMN_SPEC_ABSOLUTE_DIR=/app/process_models - SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA=${SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA:-false} + - SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME=${SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME:-acceptance_tests.yml} - RUN_BACKGROUND_SCHEDULER=true ports: - "7000:7000" diff --git a/src/spiffworkflow_backend/api.yml b/src/spiffworkflow_backend/api.yml index 7f2fbc91a..2bfa117ea 100755 --- a/src/spiffworkflow_backend/api.yml +++ b/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/src/spiffworkflow_backend/models/process_group.py b/src/spiffworkflow_backend/models/process_group.py index 381f8f63b..9efc8cf5e 100644 --- a/src/spiffworkflow_backend/models/process_group.py +++ b/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/src/spiffworkflow_backend/routes/process_api_blueprint.py b/src/spiffworkflow_backend/routes/process_api_blueprint.py index 938e6cf39..e37f2d0bd 100644 --- a/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -155,13 +155,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 = { @@ -170,6 +171,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) @@ -198,9 +200,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: @@ -226,9 +229,14 @@ 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) + process_group = process_model_service.get_process_group( + un_modify_modified_process_model_id(process_group_id) + ) if process_group is None: raise ApiError( error_code="process_model_could_not_be_created", diff --git a/src/spiffworkflow_backend/routes/user.py b/src/spiffworkflow_backend/routes/user.py index 662992721..ed5961418 100644 --- a/src/spiffworkflow_backend/routes/user.py +++ b/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/src/spiffworkflow_backend/services/process_model_service.py b/src/spiffworkflow_backend/services/process_model_service.py index c650e1f55..d64596cb8 100644 --- a/src/spiffworkflow_backend/services/process_model_service.py +++ b/src/spiffworkflow_backend/services/process_model_service.py @@ -268,12 +268,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( @@ -283,6 +288,7 @@ class ProcessModelService(FileSystemService): ) ) process_group.process_models.sort() + # process_group.process_groups.sort() return process_group def __scan_spec(