Skip to content

Commit

Permalink
Merge pull request #447 from DrDroidLab/fix_playbook_creation_flow
Browse files Browse the repository at this point in the history
Adds changes to allow playbook creation in standard workflows
  • Loading branch information
dimittal authored Aug 11, 2024
2 parents 5f9eef5 + 78f8519 commit de91678
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion executor/workflows/crud/workflows_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def update_or_create_db_workflow(account: Account, created_by, workflow_proto: W
db_playbooks = get_db_playbooks(account, playbook_ids=playbook_ids, is_active=True)
if update_mode and db_playbooks.count() != len(playbook_ids):
return None, 'Invalid Playbooks in Workflow Config'
elif not update_mode:
elif not update_mode and db_playbooks.count() != len(playbook_ids):
try:
db_playbooks = []
for pb in playbooks:
Expand Down
15 changes: 10 additions & 5 deletions executor/workflows/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,14 @@ def test_workflow_notification(user, account_id, workflow, message_type):
playbook_execution = playbook_executions.first()
pe_proto: PlaybookExecution = playbook_execution.proto
p_proto = pe_proto.playbook
playbook_url = build_absolute_uri(None, settings.PLATFORM_PLAYBOOKS_PAGE_LOCATION.format(p_proto.id.value),
settings.PLATFORM_PLAYBOOKS_PAGE_SITE_HTTP_PROTOCOL,
settings.PLATFORM_PLAYBOOKS_PAGE_USE_SITE)

pb_exec_location = settings.PLATFORM_PLAYBOOKS_EXECUTION_PAGE_LOCATION.format(
p_proto.id.value, pe_proto.playbook_run_id.value)
pb_exec_protocol = settings.PLATFORM_PLAYBOOKS_PAGE_SITE_HTTP_PROTOCOL
pb_exec_use_sites = settings.PLATFORM_PLAYBOOKS_PAGE_USE_SITE

playbook_execution_url = build_absolute_uri(None, pb_exec_location, pb_exec_protocol, pb_exec_use_sites)

step_execution_logs = pe_proto.step_execution_logs
execution_output: [InterpretationProto] = playbook_step_execution_result_interpret(step_execution_logs)
if workflow.actions[0].type == WorkflowActionProto.Type.SLACK_MESSAGE or workflow.actions[
Expand All @@ -370,15 +375,15 @@ def test_workflow_notification(user, account_id, workflow, message_type):
type=InterpretationProto.Type.TEXT,
title=StringValue(value=f'Testing Workflow: "{workflow.name.value}"'),
description=StringValue(
value=f'This is a sample run of <{playbook_url}|{p_proto.name.value}> playbook.'),
value=f'This is a sample run of <{playbook_execution_url}|{p_proto.name.value}> playbook.'),
model_type=InterpretationProto.ModelType.WORKFLOW_EXECUTION
)
else:
workflow_test_message = InterpretationProto(
type=InterpretationProto.Type.TEXT,
title=StringValue(value=f'Testing Workflow: "{workflow.name.value}"'),
description=StringValue(
value=f'This is a sample run of [{p_proto.name.value}]({playbook_url}) playbook.'),
value=f'This is a sample run of [{p_proto.name.value}]({playbook_execution_url}) playbook.'),
model_type=InterpretationProto.ModelType.WORKFLOW_EXECUTION
)
execution_output.insert(0, workflow_test_message)
Expand Down

0 comments on commit de91678

Please sign in to comment.