Skip to content

Commit 1618ff9

Browse files
author
Rohan Bansal
committed
fix: cyclical imports
1 parent fac9308 commit 1618ff9

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

frappe/integrations/doctype/webhook/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# For license information, please see license.txt
44

55
from __future__ import unicode_literals
6+
67
import frappe
78

89

@@ -54,9 +55,15 @@ def _webhook_request(webhook):
5455
event_list.append('on_change')
5556
event_list.append('before_update_after_submit')
5657

58+
from frappe.integrations.doctype.webhook.webhook import get_context
59+
5760
for webhook in webhooks_for_doc:
61+
trigger_webhook = False
5862
event = method if method in event_list else None
63+
if not webhook.condition:
64+
trigger_webhook = True
65+
elif frappe.safe_eval(webhook.condition, eval_locals=get_context(doc)):
66+
trigger_webhook = True
5967

60-
if webhook.condition and frappe.safe_eval(webhook.condition, None, {"doc": doc}):
61-
if event and webhook.webhook_docevent == event:
62-
_webhook_request(webhook)
68+
if trigger_webhook and event and webhook.webhook_docevent == event:
69+
_webhook_request(webhook)

frappe/integrations/doctype/webhook/webhook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def validate_condition(self):
3939
temp_doc = frappe.new_doc(self.webhook_doctype)
4040
if self.condition:
4141
try:
42-
frappe.safe_eval(self.condition, eval_globals=None, eval_locals=get_context(temp_doc))
42+
frappe.safe_eval(self.condition, eval_locals=get_context(temp_doc))
4343
except Exception as e:
4444
frappe.throw(_(e))
4545

0 commit comments

Comments
 (0)