feat: add admin-controlled event service
Summary
Adds an admin-controlled event service that lets admins define named events
with filters (language, media type, categories), a page context, and an active
date range. Extends the service so admins can wire up which event a page sees
via a PageEventLink table — clients send an X-Page-Route header and get
back the linked event's filters, with no query-param changes needed on the
client side.
Changes
Original
-
Eventmodel with JSONB filters,page_context,start_date/end_date, andis_activeflag - 6 CRUD endpoints under
/api/v1/events/— all admin-only exceptGET /active -
GET /records/next-for-reviewgains optionalevent_idparam — applies the event's predefined filters when no explicit filter is passed by the client - Alembic migration
b4e2a1f9c3d5creates theeventtable
New in this update
-
PageEventLinkmodel (pageeventlinktable) — maps a page route string to an event; one link per route, admin-controlled -
GET /events/activeupdated — drops?page=query param, now reads theX-Page-Routerequest header and looks up the linked event; returnsnullif no link exists or the event is inactive / outside its schedule window -
POST /events/page-links— create or update a page-route → event link (upsert if route already exists); admin only -
GET /events/page-links— list all links; admin only -
DELETE /events/page-links/{link_id}— remove a link; admin only - Migration
a3b4c5d6e7f8creates thepageeventlinktable - Merge migrations and stubs added to resolve multi-branch alembic heads
Test plan
-
POST /events— create an event as admin -
GET /events— list all events as admin -
GET /events/{id}— get single event -
PUT /events/{id}— update as admin -
DELETE /events/{id}— deactivate as admin -
POST /events/page-links— link a page route to an event (upsert) -
GET /events/page-links— list all links as admin -
DELETE /events/page-links/{link_id}— remove a link -
GET /events/activewithX-Page-Routeheader — returns linked event -
GET /events/activewith inactive/missing link — returnsnull -
Non-admin blocked from page-link endpoints — 403
Closes #128 (closed)
Edited by Gunaputra Nagendra Pavan Yedida