Skip to content

fix(permissions): scope tickets and bookings by attendee, not row creator - #359

Merged
harshtandiya merged 1 commit into
mainfrom
backport-358-to-main
Aug 17, 2026
Merged

fix(permissions): scope tickets and bookings by attendee, not row creator#359
harshtandiya merged 1 commit into
mainfrom
backport-358-to-main

Conversation

@harshtandiya

Copy link
Copy Markdown
Collaborator

Manual backport of #358 to main.

The Backport action failed on this one and it is not the action's fault. On develop the fix lives inside buzz/permissions.py, the team-multi-tenancy module from #312, which main does not have. The cherry-pick hit CONFLICT (modify/delete): buzz/permissions.py deleted in HEAD, so there was nothing to auto-resolve. Everything else in the commit applied cleanly.

This reimplements the same rule against main's permission model instead.

The bug

My Tickets showed nothing to the people the tickets belong to. if_owner on the Buzz User read permission decides "mine" by owner — whoever created the row. A ticket created by the booker, or a guest-checkout booking created as Administrator, names neither the attendee nor the buyer, so both were invisible.

What changed

  • if_owner comes off the Buzz User read permission on Event Ticket and Event Booking. Frappe ANDs it onto every query, so no attendee clause could ever have passed alongside it.
  • New buzz/permissions.py with a permission_query_conditions / has_permission pair for both doctypes. Matches owner, plus the column naming the person (Event Ticket.attendee_email, Event Booking.user), plus tickets belonging to a booking the user made. System Manager, Event Manager and Administrator are unaffected — they short-circuit to full access.
  • TicketService.details asked its own attendee-only question and would have rejected the rows the list now shows. It asks the read permission instead.
  • booking_owned_by_user compared owner, so a guest-checkout buyer never got their own booking back.
  • Delete comes off the Buzz User role on Event Booking. Bookings are cancelled, never deleted; with if_owner gone the grant would have let a buyer delete their own draft booking and its child rows through the document API.
  • TicketsList.vue drops its attendee_email filter — the permission query does that now, and the filter would have hidden tickets the user booked for others.

Not the same file as develop

main's buzz/permissions.py is a stripped module: no teams, no Buzz Team Membership, just the ownership question. Function names match develop's (belongs_to_user, my_bookings, IDENTITY_FIELDS) so that whenever the teams stack lands on main, develop's version overwrites this one rather than merging against it.

derived_has_permission's unstamped-event carve-out from #358 has no counterpart here — there are no team-stamped events on main.

Verified

bench --site buzz.localhost run-tests on the ticketing, tickets API, guest booking, check-in, sponsorships and talk proposal modules, plus the 9 new tests in buzz/test_permissions.py. All green.

…ator
Backport of #358. `develop` carries the fix inside the team permission hooks
(`buzz/permissions.py`), which `main` does not have, so the cherry-pick could
not apply. This reimplements the same rule against `main`'s permission model.
My Tickets showed nothing to the people the tickets belong to. `if_owner` on the
Buzz User read permission decided "mine" by `owner` — whoever created the row —
so a ticket created by the booker, or a guest-checkout booking created as
Administrator, was invisible to the attendee and to the buyer.
`if_owner` comes off both doctypes and the decision moves to a pair of hooks in
`buzz.permissions`, which match the column that names the person:
`Event Ticket.attendee_email`, `Event Booking.user`, plus tickets belonging to a
booking the user made. System Manager and Event Manager still read every row.
`TicketService.details` asked its own attendee-only question and would have
rejected the rows the list now shows; it asks the read permission instead.
`booking_owned_by_user` compared `owner`, so a guest-checkout buyer never got
their own booking back.
Delete also comes off the Buzz User role on Event Booking. Bookings are
cancelled, never deleted; with `if_owner` gone the grant would have let a buyer
delete their own draft booking and its child rows through the document API.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@harshtandiyaharshtandiya added the backport This PR / Issue is a backport for a branch other than develop label Aug 17, 2026
@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces creator-based ticket and booking visibility with attendee/buyer-aware permission hooks and aligns ticket details and dashboard discovery with those rules.

  • Adds query and document permission checks for ticket attendees, booking buyers, row creators, and privileged operational roles.
  • Allows buyers to inspect tickets purchased for other attendees while withholding booking details from unrelated attendees.
  • Removes portal booking deletion and the dashboard’s attendee-only filter.
  • Adds integration coverage for list, read, write, delete, and privileged-role behavior.

Confidence Score: 5/5

The PR appears safe to merge, with the new permission model consistently enforced across list and document access.

The changed hooks scope bookings and tickets to their creator, named user or attendee, and booking buyer while preserving privileged access and retaining role-level restrictions on writes and deletion; no actionable changed-code failure remains.

Important Files Changed

FilenameOverview
buzz/permissions.pyIntroduces consistent owner, attendee, and buyer scoping for query-level and document-level permission checks.
buzz/hooks.pyRegisters the new permission handlers for Event Booking and Event Ticket without disturbing the existing Talk Proposal hooks.
buzz/api/tickets/services.pyDelegates ticket-detail authorization to the shared read permission and returns booking data to its recorded buyer or creator.
buzz/ticketing/doctype/event_booking/event_booking.jsonRemoves creator-only scoping and portal deletion while retaining the intended booking read/write capabilities.
buzz/ticketing/doctype/event_ticket/event_ticket.jsonRemoves creator-only read scoping so the new attendee and buyer permission conditions can govern visibility.
dashboard/src/pages/TicketsList.vueRemoves the attendee-only client filter so server-authorized tickets booked for other people remain discoverable.
buzz/test_permissions.pyCovers attendee, buyer, outsider, creator, deletion, write, and privileged-role permission behavior.

Reviews (1): Last reviewed commit: "fix(permissions): scope tickets and book..." | Re-trigger Greptile

@harshtandiya
harshtandiya merged commit 18cb595 into mainAug 17, 2026
9 checks passed
@harshtandiya
harshtandiya deleted the backport-358-to-main branch August 17, 2026 11:46
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backportThis PR / Issue is a backport for a branch other than develop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@harshtandiya