Skip to content

refactor: split buzz/api into domain packages - #304

Closed
github-actions[bot] wants to merge 1 commit into
mainfrom
backport-295-to-main
Closed

refactor: split buzz/api into domain packages#304
github-actions[bot] wants to merge 1 commit into
mainfrom
backport-295-to-main

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #295 to main.

* refactor: split buzz/api into domain packages
buzz/api/__init__.py held 1364 lines covering booking, tickets,
sponsorships, check-in, account, campaigns and coupons in one module.
Since a Frappe endpoint's URL is its dotted module path, that layout also
made the public API surface unreadable.
Each domain now owns a package, so an endpoint's URL names its domain:
buzz.api.booking.process_booking rather than buzz.api.process_booking.
forms.py, auth.py and proposals.py become packages of the same shape.
Function bodies are unchanged; this is relocation only. Landed alongside
are api/schemas.py and api/exceptions.py, the pydantic and error base
classes later PRs build on, currently unused.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* refactor(dashboard): point API calls at the domain packages
Follows the backend split: every createResource url moves from
buzz.api.<fn> to buzz.api.<domain>.<fn>. String changes only.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* docs: update ARCHITECTURE endpoint paths for the api split
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(api): give BuzzAPIError class-defined user messages
The base error carried only http_status_code, so every call site still had
to pass its own message string and no default copy existed.
Subclasses now declare title and message as class attributes, raised via a
throw() classmethod:
class AlreadyRegistered(Conflict):
title = _lt("Already Registered")
message = _lt("You have already registered your interest.")
AlreadyRegistered.throw()
throw() routes through frappe.throw so the text lands in _server_messages,
which is what the dashboard reads as err.messages[0]. A bare raise skips
msgprint and leaves the user with "Internal Server Error" — covered by a
test so the distinction stays visible.
Messages use _lt rather than _ because class bodies run at import, before a
request has a language. frappe's translation extractor already scans _lt.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit 66396ad)
@github-actionsgithub-actionsBot added the backport This PR / Issue is a backport for a branch other than develop label Jul 29, 2026
@harshtandiya
harshtandiya deleted the backport-295-to-main branch July 29, 2026 18:41
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