From 1bd6a199f3931ccfa37b6ebe296940cdb2e17976 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 27 Oct 2022 11:47:53 -0400 Subject: [PATCH] Don't need parent. Just use the whole path for the group id --- src/spiffworkflow_backend/api.yml | 2 -- src/spiffworkflow_backend/models/process_group.py | 3 +-- .../services/file_system_service.py | 4 ++-- .../services/process_model_service.py | 2 +- .../integration/test_nested_groups.py | 9 +++------ 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/spiffworkflow_backend/api.yml b/src/spiffworkflow_backend/api.yml index 8a296d2b..335da19f 100755 --- a/src/spiffworkflow_backend/api.yml +++ b/src/spiffworkflow_backend/api.yml @@ -1620,8 +1620,6 @@ components: type: string name: type: string - parent: - type: string display_name: type: string display_order: diff --git a/src/spiffworkflow_backend/models/process_group.py b/src/spiffworkflow_backend/models/process_group.py index 9ce56482..0b100ed4 100644 --- a/src/spiffworkflow_backend/models/process_group.py +++ b/src/spiffworkflow_backend/models/process_group.py @@ -20,7 +20,6 @@ class ProcessGroup: id: str # A unique string name, lower case, under scores (ie, 'my_group') display_name: str - parent: str = '' display_order: int | None = 0 admin: bool | None = False process_models: list[ProcessModelInfo] = field( @@ -47,7 +46,7 @@ class ProcessGroupSchema(Schema): """Meta.""" model = ProcessGroup - fields = ["id", "display_name", "display_order", "admin", "process_models", "parent"] + fields = ["id", "display_name", "display_order", "admin", "process_models"] process_models = marshmallow.fields.List( marshmallow.fields.Nested( diff --git a/src/spiffworkflow_backend/services/file_system_service.py b/src/spiffworkflow_backend/services/file_system_service.py index d152dcfa..3b23ce1b 100644 --- a/src/spiffworkflow_backend/services/file_system_service.py +++ b/src/spiffworkflow_backend/services/file_system_service.py @@ -32,9 +32,9 @@ class FileSystemService: return os.path.join(app_root, "..", dir_name) @staticmethod - def process_group_path(name: str, parent: str) -> str: + def process_group_path(name: str) -> str: """Category_path.""" - return os.path.join(FileSystemService.root_path(), parent, name) + return os.path.join(FileSystemService.root_path(), name) @staticmethod def full_path_from_relative_path(relative_path: str) -> str: diff --git a/src/spiffworkflow_backend/services/process_model_service.py b/src/spiffworkflow_backend/services/process_model_service.py index 53cc0639..4f3d4512 100644 --- a/src/spiffworkflow_backend/services/process_model_service.py +++ b/src/spiffworkflow_backend/services/process_model_service.py @@ -189,7 +189,7 @@ class ProcessModelService(FileSystemService): def update_process_group(self, process_group: ProcessGroup) -> ProcessGroup: """Update_process_group.""" - cat_path = self.process_group_path(process_group.id, process_group.parent) + cat_path = self.process_group_path(process_group.id) os.makedirs(cat_path, exist_ok=True) json_path = os.path.join(cat_path, self.CAT_JSON_FILE) with open(json_path, "w") as cat_json: diff --git a/tests/spiffworkflow_backend/integration/test_nested_groups.py b/tests/spiffworkflow_backend/integration/test_nested_groups.py index eda6e076..26bd7009 100644 --- a/tests/spiffworkflow_backend/integration/test_nested_groups.py +++ b/tests/spiffworkflow_backend/integration/test_nested_groups.py @@ -54,11 +54,10 @@ class TestNestedGroups(BaseTest): ) process_group_b = ProcessGroup( - id="group_b", + id="group_a/group_b", display_name="Group B", display_order=0, admin=False, - parent='group_a' ) response_b = client.post( "/v1.0/process-groups", @@ -68,11 +67,10 @@ class TestNestedGroups(BaseTest): ) process_group_c = ProcessGroup( - id="group_c", + id="group_a/group_b/group_c", display_name="Group C", display_order=0, admin=False, - parent='group_a/group_b' ) response_c = client.post( "/v1.0/process-groups", @@ -104,11 +102,10 @@ class TestNestedGroups(BaseTest): ) process_group_b = ProcessGroup( - id="group_b", + id="group_a/group_b", display_name="Group B", display_order=0, admin=False, - parent='group_a' ) response_b = client.post( "/v1.0/process-groups",