Skip to content

fix(ticketing): render email templates without a permission check (backport #369) - #370

Merged
harshtandiya merged 1 commit into
mainfrom
backport-369-to-main
Aug 20, 2026
Merged

fix(ticketing): render email templates without a permission check (backport #369)#370
harshtandiya merged 1 commit into
mainfrom
backport-369-to-main

Conversation

@harshtandiya

Copy link
Copy Markdown
Collaborator

What changed

Manual backport of #369 to main — the bot's cherry-pick failed on two import
blocks. main predates Buzz Team Settings, so event_ticket.py there has no
get_event_team_settings import (it falls back to the Buzz Settings single
instead of the team default), and the test module has no set_team_settings
import either. Both hunks resolved by keeping main's imports and adding only
render_email_template. The fix itself applied clean to all three call sites.

One deliberate deviation from #369: TestRenderEmailTemplate used
create_user from test_buzz_team, which does not exist on main (no Buzz
Team 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(), which
reads the template as the session user. Read access is Desk User /
System Manager only, so every attendee-facing send raised PermissionError
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 it
down to main would drop doctypes. Ruff clean; leaving the suite to CI.
Covered on develop by event_ticket 12, event_booking 40, booking API 33,
sponsorship_enquiry 4.

* 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)
@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The 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.

  • Adds a shared render_email_template utility.
  • Uses it for ticket, booking-confirmation, and sponsor pitch-deck emails.
  • Adds coverage for Website User and Guest rendering.

Confidence Score: 5/5

The 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.

Important Files Changed

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

@harshtandiya
harshtandiya merged commit cc1ed9b into main Aug 20, 2026
8 checks passed
@harshtandiya
harshtandiya deleted the backport-369-to-main branch August 20, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant