fix(ticketing): render email templates without a permission check (backport #369) - #370
Merged
Conversation
* fix(ticketing): render email templates without a permission check Frappe's get_email_template() is whitelisted and reads the Email Template as the session user. Public bookings and sponsorship enquiries submit as Guest, who has no read permission on Email Template, so the render raised PermissionError. On tickets that error was swallowed by on_submit, leaving the attendee with a confirmed booking and no email. Route all three call sites through render_email_template(), which formats the template directly off the doc. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(ticketing): pin email rendering to run without Desk permissions The guest ticket test leaned on a mock of frappe's whitelisted helper, which only bit because that import was function-local — the same mock is a no-op for the module-level imports in Event Booking and Sponsorship Enquiry. Assert the invariant on render_email_template() instead: a Website User with no read access on Email Template still gets a rendered subject and message. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit b724d91)
Contributor
Greptile SummaryThe PR replaces permission-checked Email Template rendering in attendee-facing email paths with a server-side helper so Guest and Website User flows can render configured templates.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code defects identified. The new helper preserves the existing formatted-email contract while removing the permission barrier from the three intended guest-facing notification paths, and template selection remains restricted to trusted configuration.
|
| Filename | Overview |
|---|---|
| buzz/utils.py | Adds the shared server-side Email Template rendering helper used by guest-facing notification flows. |
| buzz/ticketing/doctype/event_ticket/event_ticket.py | Routes configured ticket templates through the new helper while preserving fallback templates and attachment behavior. |
| buzz/ticketing/doctype/event_booking/event_booking.py | Routes booking-confirmation templates through the new helper without changing recipient, context, or fallback behavior. |
| buzz/proposals/doctype/sponsorship_enquiry/sponsorship_enquiry.py | Routes sponsor pitch-deck templates through the new helper while preserving event/global precedence and delivery settings. |
| buzz/ticketing/doctype/event_ticket/test_event_ticket.py | Adds integration coverage proving Website Users and Guest ticket flows can render configured Email Templates. |
Reviews (1): Last reviewed commit: "fix(ticketing): render email templates w..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Manual backport of #369 to
main— the bot's cherry-pick failed on two importblocks.
mainpredates Buzz Team Settings, soevent_ticket.pythere has noget_event_team_settingsimport (it falls back to theBuzz Settingssingleinstead of the team default), and the test module has no
set_team_settingsimport either. Both hunks resolved by keeping
main's imports and adding onlyrender_email_template. The fix itself applied clean to all three call sites.One deliberate deviation from #369:
TestRenderEmailTemplateusedcreate_userfromtest_buzz_team, which does not exist onmain(no BuzzTeam doctype), so the Website User is created inline instead.
Original: ticket, booking-confirmation and sponsor pitch-deck emails rendered
their Email Template through frappe's whitelisted
get_email_template(), whichreads the template as the session user. Read access is
Desk User/System Manageronly, so every attendee-facing send raisedPermissionError—swallowed by
on_submit, leaving a confirmed booking and no email.Demo
No UI change.
skip-demo.Testing
Not run locally — the bench's app checkout is on
develop, and migrating itdown to
mainwould drop doctypes. Ruff clean; leaving the suite to CI.Covered on
developby event_ticket 12, event_booking 40, booking API 33,sponsorship_enquiry 4.