Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions django_forms_workflows/workflow_builder_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,26 @@ def is_valid_field_name(value):
f"Notification rule {rule_index} references workflow stage ID {stage_id}, but that stage is not present in the submitted builder graph."
)

notify_submitter = rule_data.get("notify_submitter")
notify_stage_assignees = rule_data.get("notify_stage_assignees")
notify_stage_groups = rule_data.get("notify_stage_groups")

for flag_name, flag_value in (
("notify_submitter", notify_submitter),
("notify_stage_assignees", notify_stage_assignees),
("notify_stage_groups", notify_stage_groups),
):
if flag_value is not None and not isinstance(flag_value, bool):
add_error(
f"Notification rule {rule_index} field '{flag_name}' must be a boolean."
)

has_recipients = bool(
rule_data.get("notify_submitter")
(notify_submitter is True)
or rule_data.get("email_field")
or rule_data.get("static_emails")
or rule_data.get("notify_stage_assignees")
or rule_data.get("notify_stage_groups")
or (notify_stage_assignees is True)
or (notify_stage_groups is True)
or (rule_data.get("notify_groups") or [])
)
if not has_recipients:
Expand Down Expand Up @@ -2629,7 +2643,12 @@ def graph_action_ids(graph):
rule_id_text = str(raw_rule_id).strip()
if not rule_id_text.isascii() or not rule_id_text.isdigit():
raise BuilderValidationError("Invalid notification rule identifier.")
normalized_rule_id = int(rule_id_text)
try:
normalized_rule_id = int(rule_id_text)
except ValueError as exc:
raise BuilderValidationError(
"Invalid notification rule identifier."
) from exc
if not 0 < normalized_rule_id <= 2**63 - 1:
raise BuilderValidationError("Invalid notification rule identifier.")
rule_obj = existing_notification_rules.get(normalized_rule_id)
Expand Down
Loading