renamed active task to human task since we are no longer deleting them w/ burnettk
This commit is contained in:
parent
e938d81366
commit
5b11804f5f
|
@ -9,7 +9,7 @@ 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.base_test import BaseTest
|
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
||||||
|
|
||||||
from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel
|
from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel
|
||||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||||
from spiffworkflow_backend.models.user import UserModel
|
from spiffworkflow_backend.models.user import UserModel
|
||||||
from spiffworkflow_backend.services.process_instance_processor import (
|
from spiffworkflow_backend.services.process_instance_processor import (
|
||||||
|
@ -47,7 +47,7 @@ def app() -> Flask:
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def with_db_and_bpmn_file_cleanup() -> None:
|
def with_db_and_bpmn_file_cleanup() -> None:
|
||||||
"""Process_group_resource."""
|
"""Process_group_resource."""
|
||||||
db.session.query(ActiveTaskUserModel).delete()
|
db.session.query(HumanTaskUserModel).delete()
|
||||||
|
|
||||||
for model in SpiffworkflowBaseDBModel._all_subclasses():
|
for model in SpiffworkflowBaseDBModel._all_subclasses():
|
||||||
db.session.query(model).delete()
|
db.session.query(model).delete()
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
from __future__ import with_statement
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""empty message
|
"""empty message
|
||||||
|
|
||||||
Revision ID: 9538a3575b63
|
Revision ID: b86f7cc3a74b
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2022-12-19 14:51:21.949731
|
Create Date: 2022-12-19 16:20:27.715487
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = '9538a3575b63'
|
revision = 'b86f7cc3a74b'
|
||||||
down_revision = None
|
down_revision = None
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
@ -176,7 +176,7 @@ def upgrade():
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.UniqueConstraint('user_id', 'group_id', name='user_group_assignment_unique')
|
sa.UniqueConstraint('user_id', 'group_id', name='user_group_assignment_unique')
|
||||||
)
|
)
|
||||||
op.create_table('active_task',
|
op.create_table('human_task',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('process_instance_id', sa.Integer(), nullable=False),
|
sa.Column('process_instance_id', sa.Integer(), nullable=False),
|
||||||
sa.Column('actual_owner_id', sa.Integer(), nullable=True),
|
sa.Column('actual_owner_id', sa.Integer(), nullable=True),
|
||||||
|
@ -196,9 +196,9 @@ def upgrade():
|
||||||
sa.ForeignKeyConstraint(['lane_assignment_id'], ['group.id'], ),
|
sa.ForeignKeyConstraint(['lane_assignment_id'], ['group.id'], ),
|
||||||
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
|
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.UniqueConstraint('task_id', 'process_instance_id', name='active_task_unique')
|
sa.UniqueConstraint('task_id', 'process_instance_id', name='human_task_unique')
|
||||||
)
|
)
|
||||||
op.create_index(op.f('ix_active_task_completed'), 'active_task', ['completed'], unique=False)
|
op.create_index(op.f('ix_human_task_completed'), 'human_task', ['completed'], unique=False)
|
||||||
op.create_table('message_correlation',
|
op.create_table('message_correlation',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('process_instance_id', sa.Integer(), nullable=False),
|
sa.Column('process_instance_id', sa.Integer(), nullable=False),
|
||||||
|
@ -265,17 +265,17 @@ def upgrade():
|
||||||
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
|
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id')
|
||||||
)
|
)
|
||||||
op.create_table('active_task_user',
|
op.create_table('human_task_user',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('active_task_id', sa.Integer(), nullable=False),
|
sa.Column('human_task_id', sa.Integer(), nullable=False),
|
||||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['active_task_id'], ['active_task.id'], ),
|
sa.ForeignKeyConstraint(['human_task_id'], ['human_task.id'], ),
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.UniqueConstraint('active_task_id', 'user_id', name='active_task_user_unique')
|
sa.UniqueConstraint('human_task_id', 'user_id', name='human_task_user_unique')
|
||||||
)
|
)
|
||||||
op.create_index(op.f('ix_active_task_user_active_task_id'), 'active_task_user', ['active_task_id'], unique=False)
|
op.create_index(op.f('ix_human_task_user_human_task_id'), 'human_task_user', ['human_task_id'], unique=False)
|
||||||
op.create_index(op.f('ix_active_task_user_user_id'), 'active_task_user', ['user_id'], unique=False)
|
op.create_index(op.f('ix_human_task_user_user_id'), 'human_task_user', ['user_id'], unique=False)
|
||||||
op.create_table('message_correlation_message_instance',
|
op.create_table('message_correlation_message_instance',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('message_instance_id', sa.Integer(), nullable=False),
|
sa.Column('message_instance_id', sa.Integer(), nullable=False),
|
||||||
|
@ -295,9 +295,9 @@ def downgrade():
|
||||||
op.drop_index(op.f('ix_message_correlation_message_instance_message_instance_id'), table_name='message_correlation_message_instance')
|
op.drop_index(op.f('ix_message_correlation_message_instance_message_instance_id'), table_name='message_correlation_message_instance')
|
||||||
op.drop_index(op.f('ix_message_correlation_message_instance_message_correlation_id'), table_name='message_correlation_message_instance')
|
op.drop_index(op.f('ix_message_correlation_message_instance_message_correlation_id'), table_name='message_correlation_message_instance')
|
||||||
op.drop_table('message_correlation_message_instance')
|
op.drop_table('message_correlation_message_instance')
|
||||||
op.drop_index(op.f('ix_active_task_user_user_id'), table_name='active_task_user')
|
op.drop_index(op.f('ix_human_task_user_user_id'), table_name='human_task_user')
|
||||||
op.drop_index(op.f('ix_active_task_user_active_task_id'), table_name='active_task_user')
|
op.drop_index(op.f('ix_human_task_user_human_task_id'), table_name='human_task_user')
|
||||||
op.drop_table('active_task_user')
|
op.drop_table('human_task_user')
|
||||||
op.drop_table('spiff_step_details')
|
op.drop_table('spiff_step_details')
|
||||||
op.drop_index(op.f('ix_process_instance_metadata_key'), table_name='process_instance_metadata')
|
op.drop_index(op.f('ix_process_instance_metadata_key'), table_name='process_instance_metadata')
|
||||||
op.drop_table('process_instance_metadata')
|
op.drop_table('process_instance_metadata')
|
||||||
|
@ -308,8 +308,8 @@ def downgrade():
|
||||||
op.drop_index(op.f('ix_message_correlation_name'), table_name='message_correlation')
|
op.drop_index(op.f('ix_message_correlation_name'), table_name='message_correlation')
|
||||||
op.drop_index(op.f('ix_message_correlation_message_correlation_property_id'), table_name='message_correlation')
|
op.drop_index(op.f('ix_message_correlation_message_correlation_property_id'), table_name='message_correlation')
|
||||||
op.drop_table('message_correlation')
|
op.drop_table('message_correlation')
|
||||||
op.drop_index(op.f('ix_active_task_completed'), table_name='active_task')
|
op.drop_index(op.f('ix_human_task_completed'), table_name='human_task')
|
||||||
op.drop_table('active_task')
|
op.drop_table('human_task')
|
||||||
op.drop_table('user_group_assignment')
|
op.drop_table('user_group_assignment')
|
||||||
op.drop_table('secret')
|
op.drop_table('secret')
|
||||||
op.drop_table('refresh_token')
|
op.drop_table('refresh_token')
|
|
@ -17,7 +17,7 @@ from spiffworkflow_backend.models.user_group_assignment import (
|
||||||
from spiffworkflow_backend.models.principal import PrincipalModel # noqa: F401
|
from spiffworkflow_backend.models.principal import PrincipalModel # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
from spiffworkflow_backend.models.active_task import ActiveTaskModel # noqa: F401
|
from spiffworkflow_backend.models.human_task import HumanTaskModel # noqa: F401
|
||||||
from spiffworkflow_backend.models.spec_reference import (
|
from spiffworkflow_backend.models.spec_reference import (
|
||||||
SpecReferenceCache,
|
SpecReferenceCache,
|
||||||
) # noqa: F401
|
) # noqa: F401
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Active_task."""
|
"""human_task."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
@ -17,20 +17,18 @@ from spiffworkflow_backend.models.user import UserModel
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from spiffworkflow_backend.models.active_task_user import ( # noqa: F401
|
from spiffworkflow_backend.models.human_task_user import ( # noqa: F401
|
||||||
ActiveTaskUserModel,
|
HumanTaskUserModel,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ActiveTaskModel(SpiffworkflowBaseDBModel):
|
class HumanTaskModel(SpiffworkflowBaseDBModel):
|
||||||
"""ActiveTaskModel."""
|
"""HumanTaskModel."""
|
||||||
|
|
||||||
__tablename__ = "active_task"
|
__tablename__ = "human_task"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
db.UniqueConstraint(
|
db.UniqueConstraint("task_id", "process_instance_id", name="human_task_unique"),
|
||||||
"task_id", "process_instance_id", name="active_task_unique"
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
actual_owner: RelationshipProperty[UserModel] = relationship(UserModel)
|
actual_owner: RelationshipProperty[UserModel] = relationship(UserModel)
|
||||||
|
@ -54,16 +52,16 @@ class ActiveTaskModel(SpiffworkflowBaseDBModel):
|
||||||
process_model_display_name: str = db.Column(db.String(255))
|
process_model_display_name: str = db.Column(db.String(255))
|
||||||
completed: bool = db.Column(db.Boolean, default=False, nullable=False, index=True)
|
completed: bool = db.Column(db.Boolean, default=False, nullable=False, index=True)
|
||||||
|
|
||||||
active_task_users = relationship("ActiveTaskUserModel", cascade="delete")
|
human_task_users = relationship("HumanTaskUserModel", cascade="delete")
|
||||||
potential_owners = relationship( # type: ignore
|
potential_owners = relationship( # type: ignore
|
||||||
"UserModel",
|
"UserModel",
|
||||||
viewonly=True,
|
viewonly=True,
|
||||||
secondary="active_task_user",
|
secondary="human_task_user",
|
||||||
overlaps="active_task_user,users",
|
overlaps="human_task_user,users",
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def to_task(cls, task: ActiveTaskModel) -> Task:
|
def to_task(cls, task: HumanTaskModel) -> Task:
|
||||||
"""To_task."""
|
"""To_task."""
|
||||||
new_task = Task(
|
new_task = Task(
|
||||||
task.task_id,
|
task.task_id,
|
||||||
|
@ -80,7 +78,7 @@ class ActiveTaskModel(SpiffworkflowBaseDBModel):
|
||||||
if hasattr(task, "process_model_identifier"):
|
if hasattr(task, "process_model_identifier"):
|
||||||
new_task.process_model_identifier = task.process_model_identifier
|
new_task.process_model_identifier = task.process_model_identifier
|
||||||
|
|
||||||
# active tasks only have status when getting the list on the home page
|
# human tasks only have status when getting the list on the home page
|
||||||
# and it comes from the process_instance. it should not be confused with task_status.
|
# and it comes from the process_instance. it should not be confused with task_status.
|
||||||
if hasattr(task, "status"):
|
if hasattr(task, "status"):
|
||||||
new_task.process_instance_status = task.status
|
new_task.process_instance_status = task.status
|
|
@ -1,4 +1,4 @@
|
||||||
"""Active_task_user."""
|
"""human_task_user."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
@ -7,26 +7,26 @@ from flask_bpmn.models.db import db
|
||||||
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
|
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
|
||||||
from sqlalchemy import ForeignKey
|
from sqlalchemy import ForeignKey
|
||||||
|
|
||||||
from spiffworkflow_backend.models.active_task import ActiveTaskModel
|
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||||
from spiffworkflow_backend.models.user import UserModel
|
from spiffworkflow_backend.models.user import UserModel
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ActiveTaskUserModel(SpiffworkflowBaseDBModel):
|
class HumanTaskUserModel(SpiffworkflowBaseDBModel):
|
||||||
"""ActiveTaskUserModel."""
|
"""HumanTaskUserModel."""
|
||||||
|
|
||||||
__tablename__ = "active_task_user"
|
__tablename__ = "human_task_user"
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
db.UniqueConstraint(
|
db.UniqueConstraint(
|
||||||
"active_task_id",
|
"human_task_id",
|
||||||
"user_id",
|
"user_id",
|
||||||
name="active_task_user_unique",
|
name="human_task_user_unique",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
active_task_id = db.Column(
|
human_task_id = db.Column(
|
||||||
ForeignKey(ActiveTaskModel.id), nullable=False, index=True # type: ignore
|
ForeignKey(HumanTaskModel.id), nullable=False, index=True # type: ignore
|
||||||
)
|
)
|
||||||
user_id = db.Column(ForeignKey(UserModel.id), nullable=False, index=True)
|
user_id = db.Column(ForeignKey(UserModel.id), nullable=False, index=True)
|
|
@ -60,10 +60,10 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
||||||
process_initiator_id: int = db.Column(ForeignKey(UserModel.id), nullable=False)
|
process_initiator_id: int = db.Column(ForeignKey(UserModel.id), nullable=False)
|
||||||
process_initiator = relationship("UserModel")
|
process_initiator = relationship("UserModel")
|
||||||
|
|
||||||
active_tasks = relationship(
|
human_tasks = relationship(
|
||||||
"ActiveTaskModel",
|
"HumanTaskModel",
|
||||||
cascade="delete",
|
cascade="delete",
|
||||||
primaryjoin="and_(ActiveTaskModel.process_instance_id==ProcessInstanceModel.id, ActiveTaskModel.completed == False)",
|
primaryjoin="and_(HumanTaskModel.process_instance_id==ProcessInstanceModel.id, HumanTaskModel.completed == False)",
|
||||||
) # type: ignore
|
) # type: ignore
|
||||||
message_instances = relationship("MessageInstanceModel", cascade="delete") # type: ignore
|
message_instances = relationship("MessageInstanceModel", cascade="delete") # type: ignore
|
||||||
message_correlations = relationship("MessageCorrelationModel", cascade="delete") # type: ignore
|
message_correlations = relationship("MessageCorrelationModel", cascade="delete") # type: ignore
|
||||||
|
|
|
@ -40,10 +40,10 @@ from sqlalchemy.orm import selectinload
|
||||||
from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
|
from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
|
||||||
ProcessEntityNotFoundError,
|
ProcessEntityNotFoundError,
|
||||||
)
|
)
|
||||||
from spiffworkflow_backend.models.active_task import ActiveTaskModel
|
|
||||||
from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel
|
|
||||||
from spiffworkflow_backend.models.file import FileSchema
|
from spiffworkflow_backend.models.file import FileSchema
|
||||||
from spiffworkflow_backend.models.group import GroupModel
|
from spiffworkflow_backend.models.group import GroupModel
|
||||||
|
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||||
|
from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel
|
||||||
from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel
|
from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel
|
||||||
from spiffworkflow_backend.models.message_instance import MessageInstanceModel
|
from spiffworkflow_backend.models.message_instance import MessageInstanceModel
|
||||||
from spiffworkflow_backend.models.message_model import MessageModel
|
from spiffworkflow_backend.models.message_model import MessageModel
|
||||||
|
@ -862,6 +862,7 @@ def process_instance_list_for_me(
|
||||||
report_id: Optional[int] = None,
|
report_id: Optional[int] = None,
|
||||||
group_identifier: Optional[str] = None,
|
group_identifier: Optional[str] = None,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
|
"""Process_instance_list_for_me."""
|
||||||
return process_instance_list(
|
return process_instance_list(
|
||||||
process_model_identifier=process_model_identifier,
|
process_model_identifier=process_model_identifier,
|
||||||
page=page,
|
page=page,
|
||||||
|
@ -984,17 +985,17 @@ def process_instance_list(
|
||||||
|
|
||||||
if report_filter.with_relation_to_me is True:
|
if report_filter.with_relation_to_me is True:
|
||||||
process_instance_query = process_instance_query.outerjoin(
|
process_instance_query = process_instance_query.outerjoin(
|
||||||
ActiveTaskModel
|
HumanTaskModel
|
||||||
).outerjoin(
|
).outerjoin(
|
||||||
ActiveTaskUserModel,
|
HumanTaskUserModel,
|
||||||
and_(
|
and_(
|
||||||
ActiveTaskModel.id == ActiveTaskUserModel.active_task_id,
|
HumanTaskModel.id == HumanTaskUserModel.human_task_id,
|
||||||
ActiveTaskUserModel.user_id == g.user.id,
|
HumanTaskUserModel.user_id == g.user.id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
process_instance_query = process_instance_query.filter(
|
process_instance_query = process_instance_query.filter(
|
||||||
or_(
|
or_(
|
||||||
ActiveTaskUserModel.id.is_not(None),
|
HumanTaskUserModel.id.is_not(None),
|
||||||
ProcessInstanceModel.process_initiator_id == g.user.id,
|
ProcessInstanceModel.process_initiator_id == g.user.id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1178,20 +1179,25 @@ def process_instance_show_for_me(
|
||||||
process_instance_id: int,
|
process_instance_id: int,
|
||||||
process_identifier: Optional[str] = None,
|
process_identifier: Optional[str] = None,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance_id).outerjoin(
|
"""Process_instance_show_for_me."""
|
||||||
ActiveTaskModel
|
process_instance = (
|
||||||
).outerjoin(
|
ProcessInstanceModel.query.filter_by(id=process_instance_id)
|
||||||
ActiveTaskUserModel,
|
.outerjoin(HumanTaskModel)
|
||||||
|
.outerjoin(
|
||||||
|
HumanTaskUserModel,
|
||||||
and_(
|
and_(
|
||||||
ActiveTaskModel.id == ActiveTaskUserModel.active_task_id,
|
HumanTaskModel.id == HumanTaskUserModel.human_task_id,
|
||||||
ActiveTaskUserModel.user_id == g.user.id,
|
HumanTaskUserModel.user_id == g.user.id,
|
||||||
),
|
),
|
||||||
).filter(
|
)
|
||||||
|
.filter(
|
||||||
or_(
|
or_(
|
||||||
ActiveTaskUserModel.id.is_not(None),
|
HumanTaskUserModel.id.is_not(None),
|
||||||
ProcessInstanceModel.process_initiator_id == g.user.id,
|
ProcessInstanceModel.process_initiator_id == g.user.id,
|
||||||
)
|
)
|
||||||
).first()
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
if process_instance is None:
|
if process_instance is None:
|
||||||
raise (
|
raise (
|
||||||
|
@ -1202,7 +1208,11 @@ def process_instance_show_for_me(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return _get_process_instance(process_instance=process_instance, modified_process_model_identifier=modified_process_model_identifier, process_identifier=process_identifier)
|
return _get_process_instance(
|
||||||
|
process_instance=process_instance,
|
||||||
|
modified_process_model_identifier=modified_process_model_identifier,
|
||||||
|
process_identifier=process_identifier,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def process_instance_show(
|
def process_instance_show(
|
||||||
|
@ -1212,13 +1222,19 @@ def process_instance_show(
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
"""Create_process_instance."""
|
"""Create_process_instance."""
|
||||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||||
return _get_process_instance(process_instance=process_instance, modified_process_model_identifier=modified_process_model_identifier, process_identifier=process_identifier)
|
return _get_process_instance(
|
||||||
|
process_instance=process_instance,
|
||||||
|
modified_process_model_identifier=modified_process_model_identifier,
|
||||||
|
process_identifier=process_identifier,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _get_process_instance(
|
def _get_process_instance(
|
||||||
modified_process_model_identifier: str,
|
modified_process_model_identifier: str,
|
||||||
process_instance: ProcessInstanceModel,
|
process_instance: ProcessInstanceModel,
|
||||||
process_identifier: Optional[str] = None,
|
process_identifier: Optional[str] = None,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
|
"""_get_process_instance."""
|
||||||
process_model_identifier = modified_process_model_identifier.replace(":", "/")
|
process_model_identifier = modified_process_model_identifier.replace(":", "/")
|
||||||
current_version_control_revision = GitService.get_current_revision()
|
current_version_control_revision = GitService.get_current_revision()
|
||||||
|
|
||||||
|
@ -1427,36 +1443,36 @@ def process_instance_report_show(
|
||||||
def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Response:
|
def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Response:
|
||||||
"""Task_list_my_tasks."""
|
"""Task_list_my_tasks."""
|
||||||
principal = find_principal_or_raise()
|
principal = find_principal_or_raise()
|
||||||
active_tasks = (
|
human_tasks = (
|
||||||
ActiveTaskModel.query.order_by(desc(ActiveTaskModel.id)) # type: ignore
|
HumanTaskModel.query.order_by(desc(HumanTaskModel.id)) # type: ignore
|
||||||
.join(ProcessInstanceModel)
|
.join(ProcessInstanceModel)
|
||||||
.join(ActiveTaskUserModel)
|
.join(HumanTaskUserModel)
|
||||||
.filter_by(user_id=principal.user_id)
|
.filter_by(user_id=principal.user_id)
|
||||||
.filter(ActiveTaskModel.completed == False) # noqa: E712
|
.filter(HumanTaskModel.completed == False) # noqa: E712
|
||||||
# just need this add_columns to add the process_model_identifier. Then add everything back that was removed.
|
# just need this add_columns to add the process_model_identifier. Then add everything back that was removed.
|
||||||
.add_columns(
|
.add_columns(
|
||||||
ProcessInstanceModel.process_model_identifier,
|
ProcessInstanceModel.process_model_identifier,
|
||||||
ProcessInstanceModel.process_model_display_name,
|
ProcessInstanceModel.process_model_display_name,
|
||||||
ProcessInstanceModel.status,
|
ProcessInstanceModel.status,
|
||||||
ActiveTaskModel.task_name,
|
HumanTaskModel.task_name,
|
||||||
ActiveTaskModel.task_title,
|
HumanTaskModel.task_title,
|
||||||
ActiveTaskModel.task_type,
|
HumanTaskModel.task_type,
|
||||||
ActiveTaskModel.task_status,
|
HumanTaskModel.task_status,
|
||||||
ActiveTaskModel.task_id,
|
HumanTaskModel.task_id,
|
||||||
ActiveTaskModel.id,
|
HumanTaskModel.id,
|
||||||
ActiveTaskModel.process_model_display_name,
|
HumanTaskModel.process_model_display_name,
|
||||||
ActiveTaskModel.process_instance_id,
|
HumanTaskModel.process_instance_id,
|
||||||
)
|
)
|
||||||
.paginate(page=page, per_page=per_page, error_out=False)
|
.paginate(page=page, per_page=per_page, error_out=False)
|
||||||
)
|
)
|
||||||
tasks = [ActiveTaskModel.to_task(active_task) for active_task in active_tasks.items]
|
tasks = [HumanTaskModel.to_task(human_task) for human_task in human_tasks.items]
|
||||||
|
|
||||||
response_json = {
|
response_json = {
|
||||||
"results": tasks,
|
"results": tasks,
|
||||||
"pagination": {
|
"pagination": {
|
||||||
"count": len(active_tasks.items),
|
"count": len(human_tasks.items),
|
||||||
"total": active_tasks.total,
|
"total": human_tasks.total,
|
||||||
"pages": active_tasks.pages,
|
"pages": human_tasks.pages,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1510,74 +1526,74 @@ def get_tasks(
|
||||||
"""Get_tasks."""
|
"""Get_tasks."""
|
||||||
user_id = g.user.id
|
user_id = g.user.id
|
||||||
|
|
||||||
# use distinct to ensure we only get one row per active task otherwise
|
# use distinct to ensure we only get one row per human task otherwise
|
||||||
# we can get back multiple for the same active task row which throws off
|
# we can get back multiple for the same human task row which throws off
|
||||||
# pagination later on
|
# pagination later on
|
||||||
# https://stackoverflow.com/q/34582014/6090676
|
# https://stackoverflow.com/q/34582014/6090676
|
||||||
active_tasks_query = (
|
human_tasks_query = (
|
||||||
ActiveTaskModel.query.distinct()
|
HumanTaskModel.query.distinct()
|
||||||
.outerjoin(GroupModel, GroupModel.id == ActiveTaskModel.lane_assignment_id)
|
.outerjoin(GroupModel, GroupModel.id == HumanTaskModel.lane_assignment_id)
|
||||||
.join(ProcessInstanceModel)
|
.join(ProcessInstanceModel)
|
||||||
.join(UserModel, UserModel.id == ProcessInstanceModel.process_initiator_id)
|
.join(UserModel, UserModel.id == ProcessInstanceModel.process_initiator_id)
|
||||||
.filter(ActiveTaskModel.completed == False) # noqa: E712
|
.filter(HumanTaskModel.completed == False) # noqa: E712
|
||||||
)
|
)
|
||||||
|
|
||||||
if processes_started_by_user:
|
if processes_started_by_user:
|
||||||
active_tasks_query = active_tasks_query.filter(
|
human_tasks_query = human_tasks_query.filter(
|
||||||
ProcessInstanceModel.process_initiator_id == user_id
|
ProcessInstanceModel.process_initiator_id == user_id
|
||||||
).outerjoin(
|
).outerjoin(
|
||||||
ActiveTaskUserModel,
|
HumanTaskUserModel,
|
||||||
and_(
|
and_(
|
||||||
ActiveTaskUserModel.user_id == user_id,
|
HumanTaskUserModel.user_id == user_id,
|
||||||
ActiveTaskModel.id == ActiveTaskUserModel.active_task_id,
|
HumanTaskModel.id == HumanTaskUserModel.human_task_id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
active_tasks_query = active_tasks_query.filter(
|
human_tasks_query = human_tasks_query.filter(
|
||||||
ProcessInstanceModel.process_initiator_id != user_id
|
ProcessInstanceModel.process_initiator_id != user_id
|
||||||
).join(
|
).join(
|
||||||
ActiveTaskUserModel,
|
HumanTaskUserModel,
|
||||||
and_(
|
and_(
|
||||||
ActiveTaskUserModel.user_id == user_id,
|
HumanTaskUserModel.user_id == user_id,
|
||||||
ActiveTaskModel.id == ActiveTaskUserModel.active_task_id,
|
HumanTaskModel.id == HumanTaskUserModel.human_task_id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if has_lane_assignment_id:
|
if has_lane_assignment_id:
|
||||||
if group_identifier:
|
if group_identifier:
|
||||||
active_tasks_query = active_tasks_query.filter(
|
human_tasks_query = human_tasks_query.filter(
|
||||||
GroupModel.identifier == group_identifier
|
GroupModel.identifier == group_identifier
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
active_tasks_query = active_tasks_query.filter(
|
human_tasks_query = human_tasks_query.filter(
|
||||||
ActiveTaskModel.lane_assignment_id.is_not(None) # type: ignore
|
HumanTaskModel.lane_assignment_id.is_not(None) # type: ignore
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
active_tasks_query = active_tasks_query.filter(ActiveTaskModel.lane_assignment_id.is_(None)) # type: ignore
|
human_tasks_query = human_tasks_query.filter(HumanTaskModel.lane_assignment_id.is_(None)) # type: ignore
|
||||||
|
|
||||||
active_tasks = (
|
human_tasks = (
|
||||||
active_tasks_query.add_columns(
|
human_tasks_query.add_columns(
|
||||||
ProcessInstanceModel.process_model_identifier,
|
ProcessInstanceModel.process_model_identifier,
|
||||||
ProcessInstanceModel.status.label("process_instance_status"), # type: ignore
|
ProcessInstanceModel.status.label("process_instance_status"), # type: ignore
|
||||||
ProcessInstanceModel.updated_at_in_seconds,
|
ProcessInstanceModel.updated_at_in_seconds,
|
||||||
ProcessInstanceModel.created_at_in_seconds,
|
ProcessInstanceModel.created_at_in_seconds,
|
||||||
UserModel.username,
|
UserModel.username,
|
||||||
GroupModel.identifier.label("group_identifier"),
|
GroupModel.identifier.label("group_identifier"),
|
||||||
ActiveTaskModel.task_name,
|
HumanTaskModel.task_name,
|
||||||
ActiveTaskModel.task_title,
|
HumanTaskModel.task_title,
|
||||||
ActiveTaskModel.process_model_display_name,
|
HumanTaskModel.process_model_display_name,
|
||||||
ActiveTaskModel.process_instance_id,
|
HumanTaskModel.process_instance_id,
|
||||||
ActiveTaskUserModel.user_id.label("current_user_is_potential_owner"),
|
HumanTaskUserModel.user_id.label("current_user_is_potential_owner"),
|
||||||
)
|
)
|
||||||
.order_by(desc(ActiveTaskModel.id)) # type: ignore
|
.order_by(desc(HumanTaskModel.id)) # type: ignore
|
||||||
.paginate(page=page, per_page=per_page, error_out=False)
|
.paginate(page=page, per_page=per_page, error_out=False)
|
||||||
)
|
)
|
||||||
|
|
||||||
response_json = {
|
response_json = {
|
||||||
"results": active_tasks.items,
|
"results": human_tasks.items,
|
||||||
"pagination": {
|
"pagination": {
|
||||||
"count": len(active_tasks.items),
|
"count": len(human_tasks.items),
|
||||||
"total": active_tasks.total,
|
"total": human_tasks.total,
|
||||||
"pages": active_tasks.pages,
|
"pages": human_tasks.pages,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return make_response(jsonify(response_json), 200)
|
return make_response(jsonify(response_json), 200)
|
||||||
|
@ -1796,14 +1812,14 @@ def task_submit(
|
||||||
if terminate_loop and spiff_task.is_looping():
|
if terminate_loop and spiff_task.is_looping():
|
||||||
spiff_task.terminate_loop()
|
spiff_task.terminate_loop()
|
||||||
|
|
||||||
active_task = ActiveTaskModel.query.filter_by(
|
human_task = HumanTaskModel.query.filter_by(
|
||||||
process_instance_id=process_instance_id, task_id=task_id, completed=False
|
process_instance_id=process_instance_id, task_id=task_id, completed=False
|
||||||
).first()
|
).first()
|
||||||
if active_task is None:
|
if human_task is None:
|
||||||
raise (
|
raise (
|
||||||
ApiError(
|
ApiError(
|
||||||
error_code="no_active_task",
|
error_code="no_human_task",
|
||||||
message="Cannot find an active task with task id '{task_id}' for process instance {process_instance_id}.",
|
message="Cannot find an human task with task id '{task_id}' for process instance {process_instance_id}.",
|
||||||
status_code=500,
|
status_code=500,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1813,7 +1829,7 @@ def task_submit(
|
||||||
spiff_task=spiff_task,
|
spiff_task=spiff_task,
|
||||||
data=body,
|
data=body,
|
||||||
user=g.user,
|
user=g.user,
|
||||||
active_task=active_task,
|
human_task=human_task,
|
||||||
)
|
)
|
||||||
|
|
||||||
# If we need to update all tasks, then get the next ready task and if it a multi-instance with the same
|
# If we need to update all tasks, then get the next ready task and if it a multi-instance with the same
|
||||||
|
@ -1826,18 +1842,18 @@ def task_submit(
|
||||||
# last_index = next_task.task_info()["mi_index"]
|
# last_index = next_task.task_info()["mi_index"]
|
||||||
# next_task = processor.next_task()
|
# next_task = processor.next_task()
|
||||||
|
|
||||||
next_active_task_assigned_to_me = (
|
next_human_task_assigned_to_me = (
|
||||||
ActiveTaskModel.query.filter_by(
|
HumanTaskModel.query.filter_by(
|
||||||
process_instance_id=process_instance_id, completed=False
|
process_instance_id=process_instance_id, completed=False
|
||||||
)
|
)
|
||||||
.order_by(asc(ActiveTaskModel.id)) # type: ignore
|
.order_by(asc(HumanTaskModel.id)) # type: ignore
|
||||||
.join(ActiveTaskUserModel)
|
.join(HumanTaskUserModel)
|
||||||
.filter_by(user_id=principal.user_id)
|
.filter_by(user_id=principal.user_id)
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
if next_active_task_assigned_to_me:
|
if next_human_task_assigned_to_me:
|
||||||
return make_response(
|
return make_response(
|
||||||
jsonify(ActiveTaskModel.to_task(next_active_task_assigned_to_me)), 200
|
jsonify(HumanTaskModel.to_task(next_human_task_assigned_to_me)), 200
|
||||||
)
|
)
|
||||||
|
|
||||||
return Response(json.dumps({"ok": True}), status=202, mimetype="application/json")
|
return Response(json.dumps({"ok": True}), status=202, mimetype="application/json")
|
||||||
|
|
|
@ -19,8 +19,8 @@ from SpiffWorkflow.task import Task as SpiffTask # type: ignore
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
|
|
||||||
from spiffworkflow_backend.models.active_task import ActiveTaskModel
|
|
||||||
from spiffworkflow_backend.models.group import GroupModel
|
from spiffworkflow_backend.models.group import GroupModel
|
||||||
|
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||||
from spiffworkflow_backend.models.permission_assignment import PermissionAssignmentModel
|
from spiffworkflow_backend.models.permission_assignment import PermissionAssignmentModel
|
||||||
from spiffworkflow_backend.models.permission_target import PermissionTargetModel
|
from spiffworkflow_backend.models.permission_target import PermissionTargetModel
|
||||||
from spiffworkflow_backend.models.principal import MissingPrincipalError
|
from spiffworkflow_backend.models.principal import MissingPrincipalError
|
||||||
|
@ -37,8 +37,8 @@ class PermissionsFileNotSetError(Exception):
|
||||||
"""PermissionsFileNotSetError."""
|
"""PermissionsFileNotSetError."""
|
||||||
|
|
||||||
|
|
||||||
class ActiveTaskNotFoundError(Exception):
|
class HumanTaskNotFoundError(Exception):
|
||||||
"""ActiveTaskNotFoundError."""
|
"""HumanTaskNotFoundError."""
|
||||||
|
|
||||||
|
|
||||||
class UserDoesNotHaveAccessToTaskError(Exception):
|
class UserDoesNotHaveAccessToTaskError(Exception):
|
||||||
|
@ -429,17 +429,17 @@ class AuthorizationService:
|
||||||
user: UserModel,
|
user: UserModel,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Assert_user_can_complete_spiff_task."""
|
"""Assert_user_can_complete_spiff_task."""
|
||||||
active_task = ActiveTaskModel.query.filter_by(
|
human_task = HumanTaskModel.query.filter_by(
|
||||||
task_name=spiff_task.task_spec.name,
|
task_name=spiff_task.task_spec.name,
|
||||||
process_instance_id=process_instance_id,
|
process_instance_id=process_instance_id,
|
||||||
).first()
|
).first()
|
||||||
if active_task is None:
|
if human_task is None:
|
||||||
raise ActiveTaskNotFoundError(
|
raise HumanTaskNotFoundError(
|
||||||
f"Could find an active task with task name '{spiff_task.task_spec.name}'"
|
f"Could find an human task with task name '{spiff_task.task_spec.name}'"
|
||||||
f" for process instance '{process_instance_id}'"
|
f" for process instance '{process_instance_id}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
if user not in active_task.potential_owners:
|
if user not in human_task.potential_owners:
|
||||||
raise UserDoesNotHaveAccessToTaskError(
|
raise UserDoesNotHaveAccessToTaskError(
|
||||||
f"User {user.username} does not have access to update task'{spiff_task.task_spec.name}'"
|
f"User {user.username} does not have access to update task'{spiff_task.task_spec.name}'"
|
||||||
f" for process instance '{process_instance_id}'"
|
f" for process instance '{process_instance_id}'"
|
||||||
|
@ -485,7 +485,7 @@ class AuthorizationService:
|
||||||
cls.import_permissions_from_yaml_file()
|
cls.import_permissions_from_yaml_file()
|
||||||
|
|
||||||
if is_new_user:
|
if is_new_user:
|
||||||
UserService.add_user_to_active_tasks_if_appropriate(user_model)
|
UserService.add_user_to_human_tasks_if_appropriate(user_model)
|
||||||
|
|
||||||
# this cannot be None so ignore mypy
|
# this cannot be None so ignore mypy
|
||||||
return user_model # type: ignore
|
return user_model # type: ignore
|
||||||
|
|
|
@ -65,11 +65,11 @@ from SpiffWorkflow.task import Task as SpiffTask # type: ignore
|
||||||
from SpiffWorkflow.task import TaskState
|
from SpiffWorkflow.task import TaskState
|
||||||
from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore
|
from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore
|
||||||
|
|
||||||
from spiffworkflow_backend.models.active_task import ActiveTaskModel
|
|
||||||
from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel
|
|
||||||
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
|
||||||
from spiffworkflow_backend.models.group import GroupModel
|
from spiffworkflow_backend.models.group import GroupModel
|
||||||
|
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||||
|
from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel
|
||||||
from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel
|
from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel
|
||||||
from spiffworkflow_backend.models.message_correlation_message_instance import (
|
from spiffworkflow_backend.models.message_correlation_message_instance import (
|
||||||
MessageCorrelationMessageInstanceModel,
|
MessageCorrelationMessageInstanceModel,
|
||||||
|
@ -573,10 +573,10 @@ class ProcessInstanceProcessor:
|
||||||
)
|
)
|
||||||
return details_model
|
return details_model
|
||||||
|
|
||||||
def save_spiff_step_details(self, active_task: ActiveTaskModel) -> None:
|
def save_spiff_step_details(self, human_task: HumanTaskModel) -> None:
|
||||||
"""SaveSpiffStepDetails."""
|
"""SaveSpiffStepDetails."""
|
||||||
details_model = self.spiff_step_details()
|
details_model = self.spiff_step_details()
|
||||||
details_model.lane_assignment_id = active_task.lane_assignment_id
|
details_model.lane_assignment_id = human_task.lane_assignment_id
|
||||||
db.session.add(details_model)
|
db.session.add(details_model)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ class ProcessInstanceProcessor:
|
||||||
db.session.add(self.process_instance_model)
|
db.session.add(self.process_instance_model)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
active_tasks = ActiveTaskModel.query.filter_by(
|
human_tasks = HumanTaskModel.query.filter_by(
|
||||||
process_instance_id=self.process_instance_model.id
|
process_instance_id=self.process_instance_model.id
|
||||||
).all()
|
).all()
|
||||||
ready_or_waiting_tasks = self.get_all_ready_or_waiting_tasks()
|
ready_or_waiting_tasks = self.get_all_ready_or_waiting_tasks()
|
||||||
|
@ -668,14 +668,14 @@ class ProcessInstanceProcessor:
|
||||||
if "formUiSchemaFilename" in properties:
|
if "formUiSchemaFilename" in properties:
|
||||||
ui_form_file_name = properties["formUiSchemaFilename"]
|
ui_form_file_name = properties["formUiSchemaFilename"]
|
||||||
|
|
||||||
active_task = None
|
human_task = None
|
||||||
for at in active_tasks:
|
for at in human_tasks:
|
||||||
if at.task_id == str(ready_or_waiting_task.id):
|
if at.task_id == str(ready_or_waiting_task.id):
|
||||||
active_task = at
|
human_task = at
|
||||||
active_tasks.remove(at)
|
human_tasks.remove(at)
|
||||||
|
|
||||||
if active_task is None:
|
if human_task is None:
|
||||||
active_task = ActiveTaskModel(
|
human_task = HumanTaskModel(
|
||||||
process_instance_id=self.process_instance_model.id,
|
process_instance_id=self.process_instance_model.id,
|
||||||
process_model_display_name=process_model_display_name,
|
process_model_display_name=process_model_display_name,
|
||||||
form_file_name=form_file_name,
|
form_file_name=form_file_name,
|
||||||
|
@ -687,20 +687,20 @@ class ProcessInstanceProcessor:
|
||||||
task_status=ready_or_waiting_task.get_state_name(),
|
task_status=ready_or_waiting_task.get_state_name(),
|
||||||
lane_assignment_id=potential_owner_hash["lane_assignment_id"],
|
lane_assignment_id=potential_owner_hash["lane_assignment_id"],
|
||||||
)
|
)
|
||||||
db.session.add(active_task)
|
db.session.add(human_task)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
for potential_owner_id in potential_owner_hash[
|
for potential_owner_id in potential_owner_hash[
|
||||||
"potential_owner_ids"
|
"potential_owner_ids"
|
||||||
]:
|
]:
|
||||||
active_task_user = ActiveTaskUserModel(
|
human_task_user = HumanTaskUserModel(
|
||||||
user_id=potential_owner_id, active_task_id=active_task.id
|
user_id=potential_owner_id, human_task_id=human_task.id
|
||||||
)
|
)
|
||||||
db.session.add(active_task_user)
|
db.session.add(human_task_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
if len(active_tasks) > 0:
|
if len(human_tasks) > 0:
|
||||||
for at in active_tasks:
|
for at in human_tasks:
|
||||||
at.completed = True
|
at.completed = True
|
||||||
db.session.add(at)
|
db.session.add(at)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -1180,11 +1180,11 @@ class ProcessInstanceProcessor:
|
||||||
)
|
)
|
||||||
return user_tasks # type: ignore
|
return user_tasks # type: ignore
|
||||||
|
|
||||||
def complete_task(self, task: SpiffTask, active_task: ActiveTaskModel) -> None:
|
def complete_task(self, task: SpiffTask, human_task: HumanTaskModel) -> None:
|
||||||
"""Complete_task."""
|
"""Complete_task."""
|
||||||
self.increment_spiff_step()
|
self.increment_spiff_step()
|
||||||
self.bpmn_process_instance.complete_task_from_id(task.id)
|
self.bpmn_process_instance.complete_task_from_id(task.id)
|
||||||
self.save_spiff_step_details(active_task)
|
self.save_spiff_step_details(human_task)
|
||||||
|
|
||||||
def get_data(self) -> dict[str, Any]:
|
def get_data(self) -> dict[str, Any]:
|
||||||
"""Get_data."""
|
"""Get_data."""
|
||||||
|
|
|
@ -8,7 +8,7 @@ from flask_bpmn.api.api_error import ApiError
|
||||||
from flask_bpmn.models.db import db
|
from flask_bpmn.models.db import db
|
||||||
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
|
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
|
||||||
|
|
||||||
from spiffworkflow_backend.models.active_task import ActiveTaskModel
|
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||||
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
|
||||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
|
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
|
||||||
|
@ -196,7 +196,7 @@ class ProcessInstanceService:
|
||||||
spiff_task: SpiffTask,
|
spiff_task: SpiffTask,
|
||||||
data: dict[str, Any],
|
data: dict[str, Any],
|
||||||
user: UserModel,
|
user: UserModel,
|
||||||
active_task: ActiveTaskModel,
|
human_task: HumanTaskModel,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""All the things that need to happen when we complete a form.
|
"""All the things that need to happen when we complete a form.
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class ProcessInstanceService:
|
||||||
dot_dct = ProcessInstanceService.create_dot_dict(data)
|
dot_dct = ProcessInstanceService.create_dot_dict(data)
|
||||||
spiff_task.update_data(dot_dct)
|
spiff_task.update_data(dot_dct)
|
||||||
# ProcessInstanceService.post_process_form(spiff_task) # some properties may update the data store.
|
# ProcessInstanceService.post_process_form(spiff_task) # some properties may update the data store.
|
||||||
processor.complete_task(spiff_task, active_task)
|
processor.complete_task(spiff_task, human_task)
|
||||||
processor.do_engine_steps(save=True)
|
processor.do_engine_steps(save=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -7,9 +7,9 @@ from flask import g
|
||||||
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_backend.models.active_task import ActiveTaskModel
|
|
||||||
from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel
|
|
||||||
from spiffworkflow_backend.models.group import GroupModel
|
from spiffworkflow_backend.models.group import GroupModel
|
||||||
|
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||||
|
from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel
|
||||||
from spiffworkflow_backend.models.principal import PrincipalModel
|
from spiffworkflow_backend.models.principal import PrincipalModel
|
||||||
from spiffworkflow_backend.models.user import UserModel
|
from spiffworkflow_backend.models.user import UserModel
|
||||||
from spiffworkflow_backend.models.user_group_assignment import UserGroupAssignmentModel
|
from spiffworkflow_backend.models.user_group_assignment import UserGroupAssignmentModel
|
||||||
|
@ -192,15 +192,15 @@ class UserService:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_user_to_active_tasks_if_appropriate(cls, user: UserModel) -> None:
|
def add_user_to_human_tasks_if_appropriate(cls, user: UserModel) -> None:
|
||||||
"""Add_user_to_active_tasks_if_appropriate."""
|
"""Add_user_to_human_tasks_if_appropriate."""
|
||||||
group_ids = [g.id for g in user.groups]
|
group_ids = [g.id for g in user.groups]
|
||||||
active_tasks = ActiveTaskModel.query.filter(
|
human_tasks = HumanTaskModel.query.filter(
|
||||||
ActiveTaskModel.lane_assignment_id.in_(group_ids) # type: ignore
|
HumanTaskModel.lane_assignment_id.in_(group_ids) # type: ignore
|
||||||
).all()
|
).all()
|
||||||
for active_task in active_tasks:
|
for human_task in human_tasks:
|
||||||
active_task_user = ActiveTaskUserModel(
|
human_task_user = HumanTaskUserModel(
|
||||||
user_id=user.id, active_task_id=active_task.id
|
user_id=user.id, human_task_id=human_task.id
|
||||||
)
|
)
|
||||||
db.session.add(active_task_user)
|
db.session.add(human_task_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
|
@ -15,8 +15,8 @@ from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
|
||||||
from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
|
from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
|
||||||
ProcessEntityNotFoundError,
|
ProcessEntityNotFoundError,
|
||||||
)
|
)
|
||||||
from spiffworkflow_backend.models.active_task import ActiveTaskModel
|
|
||||||
from spiffworkflow_backend.models.group import GroupModel
|
from spiffworkflow_backend.models.group import GroupModel
|
||||||
|
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||||
from spiffworkflow_backend.models.process_group import ProcessGroup
|
from spiffworkflow_backend.models.process_group import ProcessGroup
|
||||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
|
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
|
||||||
|
@ -1462,15 +1462,15 @@ class TestProcessApi(BaseTest):
|
||||||
assert response.json is not None
|
assert response.json is not None
|
||||||
assert response.json["next_task"] is not None
|
assert response.json["next_task"] is not None
|
||||||
|
|
||||||
active_tasks = (
|
human_tasks = (
|
||||||
db.session.query(ActiveTaskModel)
|
db.session.query(HumanTaskModel)
|
||||||
.filter(ActiveTaskModel.process_instance_id == process_instance_id)
|
.filter(HumanTaskModel.process_instance_id == process_instance_id)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
assert len(active_tasks) == 1
|
assert len(human_tasks) == 1
|
||||||
active_task = active_tasks[0]
|
human_task = human_tasks[0]
|
||||||
response = client.get(
|
response = client.get(
|
||||||
f"/v1.0/tasks/{process_instance_id}/{active_task.task_id}",
|
f"/v1.0/tasks/{process_instance_id}/{human_task.task_id}",
|
||||||
headers=self.logged_in_headers(with_super_admin_user),
|
headers=self.logged_in_headers(with_super_admin_user),
|
||||||
)
|
)
|
||||||
assert response.json is not None
|
assert response.json is not None
|
||||||
|
|
|
@ -68,9 +68,9 @@ class TestGetLocaltime(BaseTest):
|
||||||
processor = ProcessInstanceProcessor(process_instance)
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
|
|
||||||
processor.do_engine_steps(save=True)
|
processor.do_engine_steps(save=True)
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
|
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
|
@ -78,12 +78,12 @@ class TestGetLocaltime(BaseTest):
|
||||||
spiff_task,
|
spiff_task,
|
||||||
{"timezone": "US/Pacific"},
|
{"timezone": "US/Pacific"},
|
||||||
initiator_user,
|
initiator_user,
|
||||||
active_task,
|
human_task,
|
||||||
)
|
)
|
||||||
|
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
|
|
||||||
assert spiff_task
|
assert spiff_task
|
||||||
|
|
|
@ -90,14 +90,14 @@ class TestAuthorizationService(BaseTest):
|
||||||
users["testuser2"], "read", "/v1.0/process-groups/"
|
users["testuser2"], "read", "/v1.0/process-groups/"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_user_can_be_added_to_active_task_on_first_login(
|
def test_user_can_be_added_to_human_task_on_first_login(
|
||||||
self,
|
self,
|
||||||
app: Flask,
|
app: Flask,
|
||||||
client: FlaskClient,
|
client: FlaskClient,
|
||||||
with_db_and_bpmn_file_cleanup: None,
|
with_db_and_bpmn_file_cleanup: None,
|
||||||
with_super_admin_user: UserModel,
|
with_super_admin_user: UserModel,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test_user_can_be_added_to_active_task_on_first_login."""
|
"""Test_user_can_be_added_to_human_task_on_first_login."""
|
||||||
initiator_user = self.find_or_create_user("initiator_user")
|
initiator_user = self.find_or_create_user("initiator_user")
|
||||||
assert initiator_user.principal is not None
|
assert initiator_user.principal is not None
|
||||||
# to ensure there is a user that can be assigned to the task
|
# to ensure there is a user that can be assigned to the task
|
||||||
|
@ -121,21 +121,21 @@ class TestAuthorizationService(BaseTest):
|
||||||
)
|
)
|
||||||
processor = ProcessInstanceProcessor(process_instance)
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
processor.do_engine_steps(save=True)
|
processor.do_engine_steps(save=True)
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
finance_user = AuthorizationService.create_user_from_sign_in(
|
finance_user = AuthorizationService.create_user_from_sign_in(
|
||||||
{"username": "testuser2", "sub": "open_id"}
|
{"username": "testuser2", "sub": "open_id"}
|
||||||
)
|
)
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, finance_user, active_task
|
processor, spiff_task, {}, finance_user, human_task
|
||||||
)
|
)
|
||||||
|
|
|
@ -47,7 +47,7 @@ class TestDotNotation(BaseTest):
|
||||||
|
|
||||||
processor = ProcessInstanceProcessor(process_instance)
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
processor.do_engine_steps(save=True)
|
processor.do_engine_steps(save=True)
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
|
|
||||||
user_task = processor.get_ready_user_tasks()[0]
|
user_task = processor.get_ready_user_tasks()[0]
|
||||||
form_data = {
|
form_data = {
|
||||||
|
@ -58,7 +58,7 @@ class TestDotNotation(BaseTest):
|
||||||
"invoice.dueDate": "09/30/2022",
|
"invoice.dueDate": "09/30/2022",
|
||||||
}
|
}
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, user_task, form_data, with_super_admin_user, active_task
|
processor, user_task, form_data, with_super_admin_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
expected = {
|
expected = {
|
||||||
|
|
|
@ -49,14 +49,14 @@ class TestProcessInstanceProcessor(BaseTest):
|
||||||
== "Chuck Norris doesn’t read books. He stares them down until he gets the information he wants."
|
== "Chuck Norris doesn’t read books. He stares them down until he gets the information he wants."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_sets_permission_correctly_on_active_task(
|
def test_sets_permission_correctly_on_human_task(
|
||||||
self,
|
self,
|
||||||
app: Flask,
|
app: Flask,
|
||||||
client: FlaskClient,
|
client: FlaskClient,
|
||||||
with_db_and_bpmn_file_cleanup: None,
|
with_db_and_bpmn_file_cleanup: None,
|
||||||
with_super_admin_user: UserModel,
|
with_super_admin_user: UserModel,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test_sets_permission_correctly_on_active_task."""
|
"""Test_sets_permission_correctly_on_human_task."""
|
||||||
self.create_process_group(
|
self.create_process_group(
|
||||||
client, with_super_admin_user, "test_group", "test_group"
|
client, with_super_admin_user, "test_group", "test_group"
|
||||||
)
|
)
|
||||||
|
@ -80,63 +80,63 @@ class TestProcessInstanceProcessor(BaseTest):
|
||||||
processor = ProcessInstanceProcessor(process_instance)
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
processor.do_engine_steps(save=True)
|
processor.do_engine_steps(save=True)
|
||||||
|
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
assert active_task.lane_assignment_id is None
|
assert human_task.lane_assignment_id is None
|
||||||
assert len(active_task.potential_owners) == 1
|
assert len(human_task.potential_owners) == 1
|
||||||
assert active_task.potential_owners[0] == initiator_user
|
assert human_task.potential_owners[0] == initiator_user
|
||||||
|
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, finance_user, active_task
|
processor, spiff_task, {}, finance_user, human_task
|
||||||
)
|
)
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
assert active_task.lane_assignment_id == finance_group.id
|
assert human_task.lane_assignment_id == finance_group.id
|
||||||
assert len(active_task.potential_owners) == 1
|
assert len(human_task.potential_owners) == 1
|
||||||
assert active_task.potential_owners[0] == finance_user
|
assert human_task.potential_owners[0] == finance_user
|
||||||
|
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, finance_user, active_task
|
processor, spiff_task, {}, finance_user, human_task
|
||||||
)
|
)
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
assert active_task.lane_assignment_id is None
|
assert human_task.lane_assignment_id is None
|
||||||
assert len(active_task.potential_owners) == 1
|
assert len(human_task.potential_owners) == 1
|
||||||
assert active_task.potential_owners[0] == initiator_user
|
assert human_task.potential_owners[0] == initiator_user
|
||||||
|
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
assert process_instance.status == ProcessInstanceStatus.complete.value
|
assert process_instance.status == ProcessInstanceStatus.complete.value
|
||||||
|
|
||||||
def test_sets_permission_correctly_on_active_task_when_using_dict(
|
def test_sets_permission_correctly_on_human_task_when_using_dict(
|
||||||
self,
|
self,
|
||||||
app: Flask,
|
app: Flask,
|
||||||
client: FlaskClient,
|
client: FlaskClient,
|
||||||
with_db_and_bpmn_file_cleanup: None,
|
with_db_and_bpmn_file_cleanup: None,
|
||||||
with_super_admin_user: UserModel,
|
with_super_admin_user: UserModel,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test_sets_permission_correctly_on_active_task_when_using_dict."""
|
"""Test_sets_permission_correctly_on_human_task_when_using_dict."""
|
||||||
self.create_process_group(
|
self.create_process_group(
|
||||||
client, with_super_admin_user, "test_group", "test_group"
|
client, with_super_admin_user, "test_group", "test_group"
|
||||||
)
|
)
|
||||||
|
@ -163,94 +163,94 @@ class TestProcessInstanceProcessor(BaseTest):
|
||||||
processor.do_engine_steps(save=True)
|
processor.do_engine_steps(save=True)
|
||||||
processor.save()
|
processor.save()
|
||||||
|
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
assert active_task.lane_assignment_id is None
|
assert human_task.lane_assignment_id is None
|
||||||
assert len(active_task.potential_owners) == 1
|
assert len(human_task.potential_owners) == 1
|
||||||
assert active_task.potential_owners[0] == initiator_user
|
assert human_task.potential_owners[0] == initiator_user
|
||||||
|
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, finance_user_three, active_task
|
processor, spiff_task, {}, finance_user_three, human_task
|
||||||
)
|
)
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
assert active_task.lane_assignment_id is None
|
assert human_task.lane_assignment_id is None
|
||||||
assert len(active_task.potential_owners) == 2
|
assert len(human_task.potential_owners) == 2
|
||||||
assert active_task.potential_owners == [finance_user_three, finance_user_four]
|
assert human_task.potential_owners == [finance_user_three, finance_user_four]
|
||||||
|
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
g.user = finance_user_three
|
g.user = finance_user_three
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, finance_user_three, active_task
|
processor, spiff_task, {}, finance_user_three, human_task
|
||||||
)
|
)
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
assert active_task.lane_assignment_id is None
|
assert human_task.lane_assignment_id is None
|
||||||
assert len(active_task.potential_owners) == 1
|
assert len(human_task.potential_owners) == 1
|
||||||
assert active_task.potential_owners[0] == finance_user_four
|
assert human_task.potential_owners[0] == finance_user_four
|
||||||
|
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, finance_user_four, active_task
|
processor, spiff_task, {}, finance_user_four, human_task
|
||||||
)
|
)
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
assert active_task.lane_assignment_id is None
|
assert human_task.lane_assignment_id is None
|
||||||
assert len(active_task.potential_owners) == 1
|
assert len(human_task.potential_owners) == 1
|
||||||
assert active_task.potential_owners[0] == initiator_user
|
assert human_task.potential_owners[0] == initiator_user
|
||||||
|
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
active_task = process_instance.active_tasks[0]
|
human_task = process_instance.human_tasks[0]
|
||||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||||
active_task.task_name, processor.bpmn_process_instance
|
human_task.task_name, processor.bpmn_process_instance
|
||||||
)
|
)
|
||||||
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
with pytest.raises(UserDoesNotHaveAccessToTaskError):
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, initiator_user, active_task
|
processor, spiff_task, {}, initiator_user, human_task
|
||||||
)
|
)
|
||||||
ProcessInstanceService.complete_form_task(
|
ProcessInstanceService.complete_form_task(
|
||||||
processor, spiff_task, {}, testadmin1, active_task
|
processor, spiff_task, {}, testadmin1, human_task
|
||||||
)
|
)
|
||||||
|
|
||||||
assert process_instance.status == ProcessInstanceStatus.complete.value
|
assert process_instance.status == ProcessInstanceStatus.complete.value
|
||||||
|
|
||||||
def test_does_not_recreate_active_tasks_on_multiple_saves(
|
def test_does_not_recreate_human_tasks_on_multiple_saves(
|
||||||
self,
|
self,
|
||||||
app: Flask,
|
app: Flask,
|
||||||
client: FlaskClient,
|
client: FlaskClient,
|
||||||
with_db_and_bpmn_file_cleanup: None,
|
with_db_and_bpmn_file_cleanup: None,
|
||||||
with_super_admin_user: UserModel,
|
with_super_admin_user: UserModel,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test_sets_permission_correctly_on_active_task_when_using_dict."""
|
"""Test_sets_permission_correctly_on_human_task_when_using_dict."""
|
||||||
self.create_process_group(
|
self.create_process_group(
|
||||||
client, with_super_admin_user, "test_group", "test_group"
|
client, with_super_admin_user, "test_group", "test_group"
|
||||||
)
|
)
|
||||||
|
@ -273,11 +273,11 @@ class TestProcessInstanceProcessor(BaseTest):
|
||||||
)
|
)
|
||||||
processor = ProcessInstanceProcessor(process_instance)
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
processor.do_engine_steps(save=True)
|
processor.do_engine_steps(save=True)
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
initial_active_task_id = process_instance.active_tasks[0].id
|
initial_human_task_id = process_instance.human_tasks[0].id
|
||||||
|
|
||||||
# save again to ensure we go attempt to process the active tasks again
|
# save again to ensure we go attempt to process the human tasks again
|
||||||
processor.save()
|
processor.save()
|
||||||
|
|
||||||
assert len(process_instance.active_tasks) == 1
|
assert len(process_instance.human_tasks) == 1
|
||||||
assert initial_active_task_id == process_instance.active_tasks[0].id
|
assert initial_human_task_id == process_instance.human_tasks[0].id
|
||||||
|
|
Loading…
Reference in New Issue