diff --git a/src/spiff_workflow_webapp/routes/admin_blueprint/admin_blueprint.py b/src/spiff_workflow_webapp/routes/admin_blueprint/admin_blueprint.py index f6aff657..518543e1 100644 --- a/src/spiff_workflow_webapp/routes/admin_blueprint/admin_blueprint.py +++ b/src/spiff_workflow_webapp/routes/admin_blueprint/admin_blueprint.py @@ -24,7 +24,6 @@ def process_model_run(process_model_id): result = processor.get_data() process_model = ProcessModelService().get_spec(process_model_id) - SpecFileService.get_files(process_model) bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name) return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml, result=result) @@ -34,7 +33,6 @@ def process_model_run(process_model_id): def process_model_edit(process_model_id): """Edit_bpmn.""" process_model = ProcessModelService().get_spec(process_model_id) - SpecFileService.get_files(process_model) bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name) return render_template('process_model_edit.html', bpmn_xml=bpmn_xml.decode("utf-8"), @@ -45,20 +43,19 @@ def process_model_edit(process_model_id): def process_model_save(process_model_id): """Process_model_save.""" process_model = ProcessModelService().get_spec(process_model_id) - SpecFileService.get_files(process_model, process_model.primary_file_name) SpecFileService.update_file(process_model, process_model.primary_file_name, request.get_data()) bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name) return render_template('process_model_edit.html', bpmn_xml=bpmn_xml.decode("utf-8"), process_model=process_model) -@admin_blueprint.route("/process-models//", methods=["GET"]) -def process_model_show_file(process_model_id, file_id): +@admin_blueprint.route("/process-models//", methods=["GET"]) +def process_model_show_file(process_model_id, file_name): """Process_model_show_file.""" process_model = ProcessModelService().get_spec(process_model_id) - SpecFileService.get_files(process_model) - bpmn_xml = SpecFileService.get_data(process_model, file_id) - return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml) + bpmn_xml = SpecFileService.get_data(process_model, file_name) + files = SpecFileService.get_files(process_model, extension_filter="bpmn") + return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml, files=files, current_file_name=file_name) @admin_blueprint.route("/process-groups/", methods=["GET"]) @@ -79,8 +76,10 @@ def process_groups_list(): def process_model_show(process_model_id): """Show_process_model.""" process_model = ProcessModelService().get_spec(process_model_id) - bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name) - return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml) + files = SpecFileService.get_files(process_model, extension_filter="bpmn") + current_file_name = process_model.primary_file_name + bpmn_xml = SpecFileService.get_data(process_model, current_file_name) + return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml, files=files, current_file_name=current_file_name) def find_or_create_user(username: str = "test_user1") -> Any: diff --git a/src/spiff_workflow_webapp/routes/admin_blueprint/templates/process_model_show.html b/src/spiff_workflow_webapp/routes/admin_blueprint/templates/process_model_show.html index d962de7a..e7b13740 100644 --- a/src/spiff_workflow_webapp/routes/admin_blueprint/templates/process_model_show.html +++ b/src/spiff_workflow_webapp/routes/admin_blueprint/templates/process_model_show.html @@ -49,7 +49,22 @@ html, body, #canvas {
{{ result }}
- + + {% if files %} +

BPMN Files

+
    + {% for file in files %} +
  • + {{ file.name }} + {% if file.name == current_file_name %} + (current) + {% endif %} + +
  • + {% endfor %} +
+ {% endif %} +
diff --git a/src/spiff_workflow_webapp/services/spec_file_service.py b/src/spiff_workflow_webapp/services/spec_file_service.py index 6dcda4a4..8bcaa43d 100644 --- a/src/spiff_workflow_webapp/services/spec_file_service.py +++ b/src/spiff_workflow_webapp/services/spec_file_service.py @@ -23,7 +23,7 @@ class SpecFileService(FileSystemService): """ @staticmethod - def get_files(workflow_spec: ProcessModelInfo, file_name=None, include_libraries=False) -> List[File]: + def get_files(workflow_spec: ProcessModelInfo, file_name=None, include_libraries=False, extension_filter="") -> List[File]: """ Returns all files associated with a workflow specification.""" path = SpecFileService.workflow_path(workflow_spec) files = SpecFileService._get_files(path, file_name) @@ -31,6 +31,10 @@ class SpecFileService(FileSystemService): for lib_name in workflow_spec.libraries: lib_path = SpecFileService.library_path(lib_name) files.extend(SpecFileService._get_files(lib_path, file_name)) + + if extension_filter != "": + files = filter(lambda file: file.name.endswith(extension_filter), files) + return files @staticmethod