Bladeren bron

Chore: use `Workflow.VERSION_DRAFT` instead of hardcoded `draft` (#23136)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
tags/1.7.2
Yongtao Huang 3 maanden geleden
bovenliggende
commit
ab163a5f75
No account linked to committer's email address

+ 1
- 1
api/core/tools/workflow_as_tool/tool.py Bestand weergeven

if not version: if not version:
workflow = ( workflow = (
db.session.query(Workflow) db.session.query(Workflow)
.where(Workflow.app_id == app_id, Workflow.version != "draft")
.where(Workflow.app_id == app_id, Workflow.version != Workflow.VERSION_DRAFT)
.order_by(Workflow.created_at.desc()) .order_by(Workflow.created_at.desc())
.first() .first()
) )

+ 1
- 1
api/services/workflow/workflow_converter.py Bestand weergeven

tenant_id=app_model.tenant_id, tenant_id=app_model.tenant_id,
app_id=app_model.id, app_id=app_model.id,
type=WorkflowType.from_app_mode(new_app_mode).value, type=WorkflowType.from_app_mode(new_app_mode).value,
version="draft",
version=Workflow.VERSION_DRAFT,
graph=json.dumps(graph), graph=json.dumps(graph),
features=json.dumps(features), features=json.dumps(features),
created_by=account_id, created_by=account_id,

+ 9
- 7
api/services/workflow_service.py Bestand weergeven

workflow = ( workflow = (
db.session.query(Workflow) db.session.query(Workflow)
.where( .where(
Workflow.tenant_id == app_model.tenant_id, Workflow.app_id == app_model.id, Workflow.version == "draft"
Workflow.tenant_id == app_model.tenant_id,
Workflow.app_id == app_model.id,
Workflow.version == Workflow.VERSION_DRAFT,
) )
.first() .first()
) )
tenant_id=app_model.tenant_id, tenant_id=app_model.tenant_id,
app_id=app_model.id, app_id=app_model.id,
type=WorkflowType.from_app_mode(app_model.mode).value, type=WorkflowType.from_app_mode(app_model.mode).value,
version="draft",
version=Workflow.VERSION_DRAFT,
graph=json.dumps(graph), graph=json.dumps(graph),
features=json.dumps(features), features=json.dumps(features),
created_by=account.id, created_by=account.id,
draft_workflow_stmt = select(Workflow).where( draft_workflow_stmt = select(Workflow).where(
Workflow.tenant_id == app_model.tenant_id, Workflow.tenant_id == app_model.tenant_id,
Workflow.app_id == app_model.id, Workflow.app_id == app_model.id,
Workflow.version == "draft",
Workflow.version == Workflow.VERSION_DRAFT,
) )
draft_workflow = session.scalar(draft_workflow_stmt) draft_workflow = session.scalar(draft_workflow_stmt)
if not draft_workflow: if not draft_workflow:
tenant_id=app_model.tenant_id, tenant_id=app_model.tenant_id,
) )


eclosing_node_type_and_id = draft_workflow.get_enclosing_node_type_and_id(node_config)
if eclosing_node_type_and_id:
_, enclosing_node_id = eclosing_node_type_and_id
enclosing_node_type_and_id = draft_workflow.get_enclosing_node_type_and_id(node_config)
if enclosing_node_type_and_id:
_, enclosing_node_id = enclosing_node_type_and_id
else: else:
enclosing_node_id = None enclosing_node_id = None


raise ValueError(f"Workflow with ID {workflow_id} not found") raise ValueError(f"Workflow with ID {workflow_id} not found")


# Check if workflow is a draft version # Check if workflow is a draft version
if workflow.version == "draft":
if workflow.version == Workflow.VERSION_DRAFT:
raise DraftWorkflowDeletionError("Cannot delete draft workflow versions") raise DraftWorkflowDeletionError("Cannot delete draft workflow versions")


# Check if this workflow is currently referenced by an app # Check if this workflow is currently referenced by an app

Laden…
Annuleren
Opslaan