move model
This commit is contained in:
parent
03e454c685
commit
f6def599a6
|
@ -399,6 +399,34 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/OkTrue"
|
||||
|
||||
/process-models/{modified_process_model_identifier}/move:
|
||||
parameters:
|
||||
- name: modified_process_model_identifier
|
||||
in: path
|
||||
required: true
|
||||
description: the modified process model id
|
||||
schema:
|
||||
type: string
|
||||
- name: new_location
|
||||
in: query
|
||||
required: true
|
||||
description: the new location for the process model, as a process group id
|
||||
schema:
|
||||
type: string
|
||||
put:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_move
|
||||
summary: returns the new model
|
||||
tags:
|
||||
- Process Models
|
||||
responses:
|
||||
"200":
|
||||
description: Process Model
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProcessModel"
|
||||
|
||||
|
||||
/processes:
|
||||
get:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_list
|
||||
|
|
|
@ -328,6 +328,14 @@ def process_model_show(modified_process_model_identifier: str) -> Any:
|
|||
return process_model_json
|
||||
|
||||
|
||||
def process_model_move(
|
||||
modified_process_model_identifier: str, new_location: str
|
||||
) -> flask.wrappers.Response:
|
||||
original_process_model_id = un_modify_modified_process_model_id(modified_process_model_identifier)
|
||||
new_process_model = ProcessModelService().process_model_move(original_process_model_id, new_location)
|
||||
return make_response(jsonify(new_process_model), 201)
|
||||
|
||||
|
||||
def process_model_list(
|
||||
process_group_identifier: Optional[str] = None, page: int = 1, per_page: int = 100
|
||||
) -> flask.wrappers.Response:
|
||||
|
|
|
@ -115,6 +115,17 @@ class ProcessModelService(FileSystemService):
|
|||
path = f"{FileSystemService.root_path()}/{process_model_id}"
|
||||
shutil.rmtree(path)
|
||||
|
||||
def process_model_move(self, original_process_model_id: str, new_location: str) -> ProcessModelInfo:
|
||||
original_model_path = os.path.abspath(os.path.join(FileSystemService.root_path(), original_process_model_id))
|
||||
_, model_id = os.path.split(original_model_path)
|
||||
new_relative_path = f"{new_location}/{model_id}"
|
||||
new_model_path = os.path.abspath(os.path.join(
|
||||
FileSystemService.root_path(), new_relative_path
|
||||
))
|
||||
shutil.move(original_model_path, new_model_path)
|
||||
new_process_model = self.get_process_model(new_relative_path)
|
||||
return new_process_model
|
||||
|
||||
@classmethod
|
||||
def get_process_model_from_relative_path(
|
||||
cls, relative_path: str
|
||||
|
|
Loading…
Reference in New Issue