Skip to content

Commit de91678

Browse files
authored
Merge pull request #447 from DrDroidLab/fix_playbook_creation_flow
Adds changes to allow playbook creation in standard workflows
2 parents 5f9eef5 + 78f8519 commit de91678

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

executor/workflows/crud/workflows_crud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def update_or_create_db_workflow(account: Account, created_by, workflow_proto: W
6969
db_playbooks = get_db_playbooks(account, playbook_ids=playbook_ids, is_active=True)
7070
if update_mode and db_playbooks.count() != len(playbook_ids):
7171
return None, 'Invalid Playbooks in Workflow Config'
72-
elif not update_mode:
72+
elif not update_mode and db_playbooks.count() != len(playbook_ids):
7373
try:
7474
db_playbooks = []
7575
for pb in playbooks:

executor/workflows/tasks.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,14 @@ def test_workflow_notification(user, account_id, workflow, message_type):
359359
playbook_execution = playbook_executions.first()
360360
pe_proto: PlaybookExecution = playbook_execution.proto
361361
p_proto = pe_proto.playbook
362-
playbook_url = build_absolute_uri(None, settings.PLATFORM_PLAYBOOKS_PAGE_LOCATION.format(p_proto.id.value),
363-
settings.PLATFORM_PLAYBOOKS_PAGE_SITE_HTTP_PROTOCOL,
364-
settings.PLATFORM_PLAYBOOKS_PAGE_USE_SITE)
362+
363+
pb_exec_location = settings.PLATFORM_PLAYBOOKS_EXECUTION_PAGE_LOCATION.format(
364+
p_proto.id.value, pe_proto.playbook_run_id.value)
365+
pb_exec_protocol = settings.PLATFORM_PLAYBOOKS_PAGE_SITE_HTTP_PROTOCOL
366+
pb_exec_use_sites = settings.PLATFORM_PLAYBOOKS_PAGE_USE_SITE
367+
368+
playbook_execution_url = build_absolute_uri(None, pb_exec_location, pb_exec_protocol, pb_exec_use_sites)
369+
365370
step_execution_logs = pe_proto.step_execution_logs
366371
execution_output: [InterpretationProto] = playbook_step_execution_result_interpret(step_execution_logs)
367372
if workflow.actions[0].type == WorkflowActionProto.Type.SLACK_MESSAGE or workflow.actions[
@@ -370,15 +375,15 @@ def test_workflow_notification(user, account_id, workflow, message_type):
370375
type=InterpretationProto.Type.TEXT,
371376
title=StringValue(value=f'Testing Workflow: "{workflow.name.value}"'),
372377
description=StringValue(
373-
value=f'This is a sample run of <{playbook_url}|{p_proto.name.value}> playbook.'),
378+
value=f'This is a sample run of <{playbook_execution_url}|{p_proto.name.value}> playbook.'),
374379
model_type=InterpretationProto.ModelType.WORKFLOW_EXECUTION
375380
)
376381
else:
377382
workflow_test_message = InterpretationProto(
378383
type=InterpretationProto.Type.TEXT,
379384
title=StringValue(value=f'Testing Workflow: "{workflow.name.value}"'),
380385
description=StringValue(
381-
value=f'This is a sample run of [{p_proto.name.value}]({playbook_url}) playbook.'),
386+
value=f'This is a sample run of [{p_proto.name.value}]({playbook_execution_url}) playbook.'),
382387
model_type=InterpretationProto.ModelType.WORKFLOW_EXECUTION
383388
)
384389
execution_output.insert(0, workflow_test_message)

0 commit comments

Comments
 (0)