store process model display name on active tasks and use it in API, update spiff

This commit is contained in:
burnettk 2022-09-11 22:02:24 -04:00
parent e5f991741d
commit 76ae0a3dcf
6 changed files with 21 additions and 6 deletions

View File

@ -1,8 +1,8 @@
"""empty message
Revision ID: 9005f01aecf4
Revision ID: 774ff3b4b328
Revises:
Create Date: 2022-09-09 12:55:35.301314
Create Date: 2022-09-11 21:51:30.585507
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9005f01aecf4'
revision = '774ff3b4b328'
down_revision = None
branch_labels = None
depends_on = None
@ -157,6 +157,7 @@ def upgrade():
sa.Column('task_title', sa.String(length=50), nullable=True),
sa.Column('task_type', sa.String(length=50), nullable=True),
sa.Column('task_status', sa.String(length=50), nullable=True),
sa.Column('process_model_display_name', sa.String(length=255), nullable=True),
sa.Column('task_data', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['assigned_principal_id'], ['principal.id'], ),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),

2
poetry.lock generated
View File

@ -1847,7 +1847,7 @@ pytz = "*"
type = "git"
url = "https://github.com/sartography/SpiffWorkflow"
reference = "main"
resolved_reference = "1db24c7043a3281481305310e320e27270c70f95"
resolved_reference = "0abc3c914d8c993abcf9fa02eab105e2a8cf6b71"
[[package]]
name = "sqlalchemy"

View File

@ -45,6 +45,7 @@ class ActiveTaskModel(SpiffworkflowBaseDBModel):
task_title = db.Column(db.String(50))
task_type = db.Column(db.String(50))
task_status = db.Column(db.String(50))
process_model_display_name = db.Column(db.String(255))
task_data: str = db.Column(db.Text)
@classmethod
@ -61,7 +62,7 @@ class ActiveTaskModel(SpiffworkflowBaseDBModel):
data=task_data,
process_instance_id=task.process_instance_id,
)
if hasattr(task, "process_model_identifier"):
new_task.process_name = task.process_model_identifier
if hasattr(task, "process_model_display_name"):
new_task.process_model_display_name = task.process_model_display_name
return new_task

View File

@ -110,6 +110,7 @@ class Task:
process_name: str = "",
properties: Union[dict, None] = None,
process_instance_id: Union[int, None] = None,
process_model_display_name: Union[str, None] = None,
form_schema: Union[str, None] = None,
form_ui_schema: Union[str, None] = None,
):
@ -128,6 +129,7 @@ class Task:
self.data = {}
self.process_instance_id = process_instance_id
self.process_model_display_name = process_model_display_name
self.form_schema = form_schema
self.form_ui_schema = form_ui_schema
@ -169,6 +171,7 @@ class Task:
"process_name": self.process_name,
"properties": self.properties,
"process_instance_id": self.process_instance_id,
"process_model_display_name": self.process_model_display_name,
"form_schema": self.form_schema,
"form_ui_schema": self.form_ui_schema,
}

View File

@ -691,6 +691,7 @@ def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Res
ActiveTaskModel.task_status,
ActiveTaskModel.task_id,
ActiveTaskModel.id,
ActiveTaskModel.process_model_display_name,
ActiveTaskModel.process_instance_id,
)
.paginate(page, per_page, False)
@ -754,6 +755,7 @@ def task_show(process_instance_id: int, task_id: str) -> flask.wrappers.Response
task = ProcessInstanceService.spiff_task_to_api_task(spiff_task)
task.data = spiff_task.data
task.process_name = process_model.id
task.process_model_display_name = process_model.display_name
if task.type == "UserTask":
if not form_schema_file_name:

View File

@ -430,8 +430,16 @@ class ProcessInstanceProcessor:
if "formUiSchemaFilename" in properties:
ui_form_file_name = properties["formUiSchemaFilename"]
process_model_display_name = ""
process_model_info = self.process_model_service.get_process_model(
self.process_instance_model.process_model_identifier
)
if process_model_info is not None:
process_model_display_name = process_model_info.display_name
active_task = ActiveTaskModel(
process_instance_id=self.process_instance_model.id,
process_model_display_name=process_model_display_name,
assigned_principal_id=principal.id,
form_file_name=form_file_name,
ui_form_file_name=ui_form_file_name,