Merge pull request #132 from sartography/feature/no_more_current_user

Feature/no more current user
This commit is contained in:
Dan Funk 2023-02-08 18:23:25 -05:00 committed by GitHub
commit 81da8c30a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 32 deletions

View File

@ -283,7 +283,7 @@ def task_show(process_instance_id: int, task_id: str) -> flask.wrappers.Response
_munge_form_ui_schema_based_on_hidden_fields_in_task_data(task)
if task.properties and task.data and "instructionsForEndUser" in task.properties:
if task.properties and "instructionsForEndUser" in task.properties:
if task.properties["instructionsForEndUser"]:
try:
task.properties["instructionsForEndUser"] = _render_jinja_template(

View File

@ -80,7 +80,6 @@ from spiffworkflow_backend.models.script_attributes_context import (
from spiffworkflow_backend.models.spec_reference import SpecReferenceCache
from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel
from spiffworkflow_backend.models.user import UserModel
from spiffworkflow_backend.models.user import UserModelSchema
from spiffworkflow_backend.scripts.script import Script
from spiffworkflow_backend.services.custom_parser import MyCustomParser
from spiffworkflow_backend.services.file_system_service import FileSystemService
@ -174,7 +173,7 @@ class NonTaskDataBasedScriptEngineEnvironment(BasePythonScriptEngineEnvironment)
"""NonTaskDataBasedScriptEngineEnvironment."""
self.state: Dict[str, Any] = {}
self.non_user_defined_keys = set(
[*environment_globals.keys()] + ["__builtins__", "current_user"]
[*environment_globals.keys()] + ["__builtins__"]
)
super().__init__(environment_globals)
@ -492,7 +491,6 @@ class ProcessInstanceProcessor:
subprocesses=subprocesses,
)
self.set_script_engine(self.bpmn_process_instance)
self.add_user_info_to_process_instance(self.bpmn_process_instance)
except MissingSpecError as ke:
raise ApiError(
@ -563,18 +561,6 @@ class ProcessInstanceProcessor:
return current_user
def add_user_info_to_process_instance(
self, bpmn_process_instance: BpmnWorkflow
) -> None:
"""Add_user_info_to_process_instance."""
current_user = self.current_user()
if current_user:
current_user_data = UserModelSchema().dump(current_user)
tasks = bpmn_process_instance.get_tasks(TaskState.READY)
for task in tasks:
task.data["current_user"] = current_user_data
@staticmethod
def get_bpmn_process_instance_from_workflow_spec(
spec: BpmnProcessSpec,
@ -1569,14 +1555,10 @@ class ProcessInstanceProcessor:
except WorkflowTaskException as we:
raise ApiError.from_workflow_exception("task_error", str(we), we) from we
def user_defined_task_data(self, task_data: dict) -> dict:
"""UserDefinedTaskData."""
return {k: v for k, v in task_data.items() if k != "current_user"}
def check_task_data_size(self) -> None:
"""CheckTaskDataSize."""
tasks_to_check = self.bpmn_process_instance.get_tasks(TaskState.FINISHED_MASK)
task_data = [self.user_defined_task_data(task.data) for task in tasks_to_check]
task_data = [task.data for task in tasks_to_check]
task_data_to_check = list(filter(len, task_data))
try:

View File

@ -174,11 +174,7 @@ class ProcessInstanceService:
not hasattr(spiff_task.task_spec, "lane")
or spiff_task.task_spec.lane is None
):
current_user = spiff_task.data["current_user"]
return [
current_user["id"],
]
# return [processor.process_instance_model.process_initiator_id]
return [processor.process_instance_model.process_initiator_id]
if spiff_task.task_spec.lane not in spiff_task.data:
return [] # No users are assignable to the task at this moment

View File

@ -1225,10 +1225,6 @@ class TestProcessApi(BaseTest):
assert response.json["updated_at_in_seconds"] > 0
assert response.json["status"] == "complete"
assert response.json["process_model_identifier"] == process_model_identifier
assert (
response.json["data"]["current_user"]["username"]
== with_super_admin_user.username
)
assert response.json["data"]["Mike"] == "Awesome"
assert response.json["data"]["person"] == "Kevin"
@ -2232,10 +2228,10 @@ class TestProcessApi(BaseTest):
assert process_instance.status == "error"
processor = ProcessInstanceProcessor(process_instance)
spiff_task = processor.get_task_by_bpmn_identifier(
"script_task_one", processor.bpmn_process_instance
"script_task_two", processor.bpmn_process_instance
)
assert spiff_task is not None
assert spiff_task.data != {}
assert spiff_task.data == {"my_var": "THE VAR"}
def test_process_model_file_create(
self,