Merge branch 'main' into cullerton

This commit is contained in:
mike cullerton 2022-07-21 10:12:44 -04:00
commit 9f64a27322
9 changed files with 45 additions and 31 deletions

View File

@ -1,12 +1,12 @@
"""Conftest.""" """Conftest."""
import os import os
import shutil import shutil
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
import pytest import pytest
from flask.app import Flask from flask.app import Flask
from flask_bpmn.models.db import db from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.helpers.fixture_data import find_or_create_user from spiffworkflow_backend.helpers.fixture_data import find_or_create_user
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel

View File

@ -715,11 +715,17 @@ paths:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/WorkflowSpecCategory"
responses: responses:
"200": "200":
description: One task
content:
application/json:
schema:
$ref: "#/components/schemas/Task"
"202":
description: "ok: true" description: "ok: true"
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/OkTrue" $ref: "#components/schemas/OkTrue"
components: components:
securitySchemes: securitySchemes:

View File

@ -2,8 +2,6 @@
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from SpiffWorkflow.navigation import NavItem # type: ignore
from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore
from typing import Any from typing import Any
from typing import cast from typing import cast
@ -13,6 +11,8 @@ from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from marshmallow import INCLUDE from marshmallow import INCLUDE
from marshmallow import Schema from marshmallow import Schema
from marshmallow_enum import EnumField # type: ignore from marshmallow_enum import EnumField # type: ignore
from SpiffWorkflow.navigation import NavItem # type: ignore
from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore
from sqlalchemy import ForeignKey from sqlalchemy import ForeignKey
from sqlalchemy.orm import deferred from sqlalchemy.orm import deferred
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship

View File

@ -1,7 +1,6 @@
"""APIs for dealing with process groups, process models, and process instances.""" """APIs for dealing with process groups, process models, and process instances."""
import json import json
import uuid import uuid
from SpiffWorkflow import TaskState # type: ignore
from typing import Any from typing import Any
from typing import Dict from typing import Dict
from typing import Optional from typing import Optional
@ -17,6 +16,7 @@ from flask import request
from flask.wrappers import Response from flask.wrappers import Response
from flask_bpmn.api.api_error import ApiError from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db from flask_bpmn.models.db import db
from SpiffWorkflow import TaskState # type: ignore
from sqlalchemy import desc from sqlalchemy import desc
from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
@ -553,11 +553,12 @@ def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Res
def task_show(task_id: int) -> flask.wrappers.Response: def task_show(task_id: int) -> flask.wrappers.Response:
"""Task_list_my_tasks.""" """Task_list_my_tasks."""
principal = find_principal_or_raise() principal = find_principal_or_raise()
active_task_assigned_to_me = find_active_task_by_id_or_raise(task_id, principal.id) active_task_assigned_to_me = find_active_task_by_id_or_raise(task_id, principal.id)
process_instance = ProcessInstanceModel.query.filter_by( process_instance = find_process_instance_by_id_or_raise(
id=active_task_assigned_to_me.process_instance_id active_task_assigned_to_me.process_instance_id
).first() )
process_model = get_process_model( process_model = get_process_model(
process_instance.process_model_identifier, process_instance.process_model_identifier,
process_instance.process_group_identifier, process_instance.process_group_identifier,
@ -645,7 +646,13 @@ def task_submit_user_data(
ProcessInstanceService.update_task_assignments(processor) ProcessInstanceService.update_task_assignments(processor)
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json") next_active_task_assigned_to_me = ActiveTaskModel.query.filter_by(
assigned_principal_id=principal.id, process_instance_id=process_instance.id
).first()
if next_active_task_assigned_to_me:
return make_response(jsonify(next_active_task_assigned_to_me), 200)
return Response(json.dumps({"ok": True}), status=202, mimetype="application/json")
def get_file_from_request() -> Any: def get_file_from_request() -> Any:

View File

@ -1,6 +1,16 @@
"""Process_instance_processor.""" """Process_instance_processor."""
import json import json
import time import time
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from typing import Union
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from lxml import etree # type: ignore
from SpiffWorkflow import Task as SpiffTask # type: ignore from SpiffWorkflow import Task as SpiffTask # type: ignore
from SpiffWorkflow import TaskState from SpiffWorkflow import TaskState
from SpiffWorkflow import WorkflowException from SpiffWorkflow import WorkflowException
@ -21,16 +31,6 @@ from SpiffWorkflow.specs import WorkflowSpec # type: ignore
from SpiffWorkflow.spiff.parser.process import SpiffBpmnParser # type: ignore from SpiffWorkflow.spiff.parser.process import SpiffBpmnParser # type: ignore
from SpiffWorkflow.spiff.serializer import UserTaskConverter # type: ignore from SpiffWorkflow.spiff.serializer import UserTaskConverter # type: ignore
from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from typing import Union
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from lxml import etree # type: ignore
from spiffworkflow_backend.models.active_task import ActiveTaskModel from spiffworkflow_backend.models.active_task import ActiveTaskModel
from spiffworkflow_backend.models.file import File from spiffworkflow_backend.models.file import File

View File

@ -1,5 +1,13 @@
"""Process_instance_service.""" """Process_instance_service."""
import time import time
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from SpiffWorkflow.bpmn.specs.events import EndEvent # type: ignore from SpiffWorkflow.bpmn.specs.events import EndEvent # type: ignore
from SpiffWorkflow.bpmn.specs.events import StartEvent from SpiffWorkflow.bpmn.specs.events import StartEvent
from SpiffWorkflow.bpmn.specs.ManualTask import ManualTask # type: ignore from SpiffWorkflow.bpmn.specs.ManualTask import ManualTask # type: ignore
@ -11,14 +19,6 @@ from SpiffWorkflow.specs import CancelTask # type: ignore
from SpiffWorkflow.specs import StartTask from SpiffWorkflow.specs import StartTask
from SpiffWorkflow.task import Task as SpiffTask # type: ignore from SpiffWorkflow.task import Task as SpiffTask # type: ignore
from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.process_instance import ProcessInstanceApi from spiffworkflow_backend.models.process_instance import ProcessInstanceApi
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel

View File

@ -2,7 +2,6 @@
import os import os
import shutil import shutil
from datetime import datetime from datetime import datetime
from SpiffWorkflow.bpmn.parser.ValidationException import ValidationException # type: ignore
from typing import List from typing import List
from typing import Optional from typing import Optional
from typing import Union from typing import Union
@ -11,6 +10,7 @@ from flask_bpmn.api.api_error import ApiError
from lxml import etree # type: ignore from lxml import etree # type: ignore
from lxml.etree import _Element # type: ignore from lxml.etree import _Element # type: ignore
from lxml.etree import Element as EtreeElement from lxml.etree import Element as EtreeElement
from SpiffWorkflow.bpmn.parser.ValidationException import ValidationException # type: ignore
from spiffworkflow_backend.models.file import File from spiffworkflow_backend.models.file import File
from spiffworkflow_backend.models.file import FileType from spiffworkflow_backend.models.file import FileType

View File

@ -1,8 +1,9 @@
"""User.""" """User."""
from tests.spiffworkflow_backend.helpers.example_data import ExampleDataLoader
from typing import Dict from typing import Dict
from typing import Optional from typing import Optional
from tests.spiffworkflow_backend.helpers.example_data import ExampleDataLoader
from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
ProcessEntityNotFoundError, ProcessEntityNotFoundError,
) )

View File

@ -2,8 +2,6 @@
import io import io
import json import json
import time import time
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from tests.spiffworkflow_backend.helpers.test_data import logged_in_headers
from typing import Any from typing import Any
from typing import Dict from typing import Dict
from typing import Optional from typing import Optional
@ -12,6 +10,8 @@ import pytest
from flask.app import Flask from flask.app import Flask
from flask.testing import FlaskClient from flask.testing import FlaskClient
from flask_bpmn.models.db import db from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from tests.spiffworkflow_backend.helpers.test_data import logged_in_headers
from werkzeug.test import TestResponse from werkzeug.test import TestResponse
from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( from spiffworkflow_backend.exceptions.process_entity_not_found_error import (