Merge branch 'main' into cullerton

# Conflicts:
#	poetry.lock
This commit is contained in:
mike cullerton 2022-09-06 15:50:36 -04:00
commit cf9be81768
3 changed files with 15 additions and 6 deletions

2
poetry.lock generated
View File

@ -2157,7 +2157,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "22c1b45f95769cf86303de8139a7be931a85d87d9e3c3f826e3af201a388df82"
content-hash = "3fe7680583608ddd4ea93082b0c6c250507b53b2211218e00b2df01649bd6c6b"
[metadata.files]
alabaster = [

View File

@ -49,6 +49,7 @@ types-pytz = "^2022.1.1"
python-keycloak = "^2.5.0"
APScheduler = "^3.9.1"
types-requests = "^2.28.6"
Jinja2 = "^3.1.2"
[tool.poetry.dev-dependencies]

View File

@ -8,6 +8,7 @@ from typing import Union
import connexion # type: ignore
import flask.wrappers
import jinja2
from flask import Blueprint
from flask import g
from flask import jsonify
@ -747,6 +748,12 @@ def task_show(process_instance_id: int, task_id: str) -> flask.wrappers.Response
)
if ui_form_contents:
task.form_ui_schema = ui_form_contents
elif task.type == "ManualTask":
if task.properties and task.data:
if task.properties["instructionsForEndUser"]:
task.properties["instructionsForEndUser"] = render_jinja_template(
task.properties["instructionsForEndUser"], task.data
)
return make_response(jsonify(task), 200)
@ -919,13 +926,14 @@ def prepare_form_data(
return ""
file_contents = SpecFileService.get_data(process_model, form_file).decode("utf-8")
return render_jinja_template(file_contents, task_data)
# trade out pieces like "{{variable_name}}" for the corresponding form data value
for key, value in task_data.items():
if isinstance(value, str) or isinstance(value, int):
file_contents = file_contents.replace("{{" + key + "}}", str(value))
return file_contents
def render_jinja_template(unprocessed_template: str, data: dict[str, Any]) -> str:
"""Render_jinja_template."""
jinja_environment = jinja2.Environment(autoescape=True)
template = jinja_environment.from_string(unprocessed_template)
return template.render(**data)
def get_spiff_task_from_process_instance(