Squashed 'spiffworkflow-backend/' changes from 43faebbd8..e78e32dcf
e78e32dcf Merge commit 'a26363d7145eeb5e07eb08ad4018be8a42e2076e' ec2d4ef66 pass in perm file for acceptance tests w/ burnettk eb718fd55 Merge branch 'main' into feature/nested-groups-2 1497205b1 Merge branch 'main' into feature/nested-groups-2 caa03e2f8 Fixes for adding nested groups. We pass modified ids to the api, and need to clean them up before calling services. git-subtree-dir: spiffworkflow-backend git-subtree-split: e78e32dcf92a141ead5c4c94c542b5af614dce93
This commit is contained in:
parent
a26363d714
commit
3e95f315ac
|
@ -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"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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__."""
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue