fix tests
This commit is contained in:
parent
66c5272766
commit
cb41cf7cc7
|
@ -1,5 +1,3 @@
|
||||||
from __future__ import with_statement
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,11 @@ 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("ActiveTaskModel", cascade="delete") # type: ignore
|
active_tasks = relationship(
|
||||||
|
"ActiveTaskModel",
|
||||||
|
cascade="delete",
|
||||||
|
primaryjoin="and_(ActiveTaskModel.process_instance_id==ProcessInstanceModel.id, ActiveTaskModel.completed == False)",
|
||||||
|
) # 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
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
"""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
|
||||||
from sqlalchemy import or_
|
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
@ -34,6 +33,7 @@ from sqlalchemy import and_
|
||||||
from sqlalchemy import asc
|
from sqlalchemy import asc
|
||||||
from sqlalchemy import desc
|
from sqlalchemy import desc
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
|
from sqlalchemy import or_
|
||||||
from sqlalchemy.orm import aliased
|
from sqlalchemy.orm import aliased
|
||||||
from sqlalchemy.orm import selectinload
|
from sqlalchemy.orm import selectinload
|
||||||
|
|
||||||
|
@ -870,7 +870,7 @@ def process_instance_list(
|
||||||
initiated_by_me,
|
initiated_by_me,
|
||||||
with_tasks_completed_by_me,
|
with_tasks_completed_by_me,
|
||||||
with_tasks_completed_by_my_group,
|
with_tasks_completed_by_my_group,
|
||||||
with_relation_to_me
|
with_relation_to_me,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
report_filter = (
|
report_filter = (
|
||||||
|
@ -885,7 +885,7 @@ def process_instance_list(
|
||||||
initiated_by_me,
|
initiated_by_me,
|
||||||
with_tasks_completed_by_me,
|
with_tasks_completed_by_me,
|
||||||
with_tasks_completed_by_my_group,
|
with_tasks_completed_by_my_group,
|
||||||
with_relation_to_me
|
with_relation_to_me,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -940,13 +940,21 @@ def process_instance_list(
|
||||||
|
|
||||||
print(f"report_filter.with_relation_to_me: {report_filter.with_relation_to_me}")
|
print(f"report_filter.with_relation_to_me: {report_filter.with_relation_to_me}")
|
||||||
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(ActiveTaskModel).outerjoin(ActiveTaskUserModel,
|
process_instance_query = process_instance_query.outerjoin(
|
||||||
|
ActiveTaskModel
|
||||||
|
).outerjoin(
|
||||||
|
ActiveTaskUserModel,
|
||||||
and_(
|
and_(
|
||||||
ActiveTaskModel.id == ActiveTaskUserModel.active_task_id,
|
ActiveTaskModel.id == ActiveTaskUserModel.active_task_id,
|
||||||
ActiveTaskUserModel.user_id == g.user.id,
|
ActiveTaskUserModel.user_id == g.user.id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
process_instance_query = process_instance_query.filter(or_(ActiveTaskUserModel.id.is_not(None), ProcessInstanceModel.process_initiator_id == g.user.id))
|
process_instance_query = process_instance_query.filter(
|
||||||
|
or_(
|
||||||
|
ActiveTaskUserModel.id.is_not(None),
|
||||||
|
ProcessInstanceModel.process_initiator_id == g.user.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if report_filter.initiated_by_me is True:
|
if report_filter.initiated_by_me is True:
|
||||||
process_instance_query = process_instance_query.filter(
|
process_instance_query = process_instance_query.filter(
|
||||||
|
@ -1336,6 +1344,7 @@ def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Res
|
||||||
.join(ProcessInstanceModel)
|
.join(ProcessInstanceModel)
|
||||||
.join(ActiveTaskUserModel)
|
.join(ActiveTaskUserModel)
|
||||||
.filter_by(user_id=principal.user_id)
|
.filter_by(user_id=principal.user_id)
|
||||||
|
.filter(ActiveTaskModel.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,
|
||||||
|
@ -1422,7 +1431,7 @@ def get_tasks(
|
||||||
.outerjoin(GroupModel, GroupModel.id == ActiveTaskModel.lane_assignment_id)
|
.outerjoin(GroupModel, GroupModel.id == ActiveTaskModel.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)
|
.filter(ActiveTaskModel.completed == False) # noqa: E712
|
||||||
)
|
)
|
||||||
|
|
||||||
if processes_started_by_user:
|
if processes_started_by_user:
|
||||||
|
@ -1723,7 +1732,9 @@ def task_submit(
|
||||||
# next_task = processor.next_task()
|
# next_task = processor.next_task()
|
||||||
|
|
||||||
next_active_task_assigned_to_me = (
|
next_active_task_assigned_to_me = (
|
||||||
ActiveTaskModel.query.filter_by(process_instance_id=process_instance_id, completed=False)
|
ActiveTaskModel.query.filter_by(
|
||||||
|
process_instance_id=process_instance_id, completed=False
|
||||||
|
)
|
||||||
.order_by(asc(ActiveTaskModel.id)) # type: ignore
|
.order_by(asc(ActiveTaskModel.id)) # type: ignore
|
||||||
.join(ActiveTaskUserModel)
|
.join(ActiveTaskUserModel)
|
||||||
.filter_by(user_id=principal.user_id)
|
.filter_by(user_id=principal.user_id)
|
||||||
|
|
|
@ -53,9 +53,7 @@ class ProcessInstanceReportFilter:
|
||||||
self.with_tasks_completed_by_my_group
|
self.with_tasks_completed_by_my_group
|
||||||
).lower()
|
).lower()
|
||||||
if self.with_relation_to_me is not None:
|
if self.with_relation_to_me is not None:
|
||||||
d["with_relation_to_me"] = str(
|
d["with_relation_to_me"] = str(self.with_relation_to_me).lower()
|
||||||
self.with_relation_to_me
|
|
||||||
).lower()
|
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -179,9 +177,7 @@ class ProcessInstanceReportService:
|
||||||
with_tasks_completed_by_my_group = bool_value(
|
with_tasks_completed_by_my_group = bool_value(
|
||||||
"with_tasks_completed_by_my_group"
|
"with_tasks_completed_by_my_group"
|
||||||
)
|
)
|
||||||
with_relation_to_me = bool_value(
|
with_relation_to_me = bool_value("with_relation_to_me")
|
||||||
"with_relation_to_me"
|
|
||||||
)
|
|
||||||
|
|
||||||
report_filter = ProcessInstanceReportFilter(
|
report_filter = ProcessInstanceReportFilter(
|
||||||
process_model_identifier,
|
process_model_identifier,
|
||||||
|
@ -237,9 +233,7 @@ class ProcessInstanceReportService:
|
||||||
with_tasks_completed_by_my_group
|
with_tasks_completed_by_my_group
|
||||||
)
|
)
|
||||||
if with_relation_to_me is not None:
|
if with_relation_to_me is not None:
|
||||||
report_filter.with_relation_to_me = (
|
report_filter.with_relation_to_me = with_relation_to_me
|
||||||
with_relation_to_me
|
|
||||||
)
|
|
||||||
|
|
||||||
return report_filter
|
return report_filter
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue