Manage registrations: tick registrations (or all shown) and message them (email/WhatsApp event update), mark them paid (the balance, by method), move them to another ticket (same tickets and QR codes, repriced, places checked), put their people in a room or group, export to Excel, or cancel. Each runs the same handlers as doing it one at a time, with a result per registration. POST /api/registrations/bulk, campus-checked per id. Migration 20261028170000_registrations_bulk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
3.4 KiB
JavaScript
54 lines
3.4 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const {
|
|
createRegistration,
|
|
getRegistrations,
|
|
getUserRegistrations,
|
|
getRegistrationById,
|
|
updateRegistrationStatus,
|
|
cancelRegistration,
|
|
getRegistrationsByEvent,
|
|
createManualRegistration,
|
|
updateRegistrationOptions,
|
|
submitFormResponses, replaceFormResponses,
|
|
getFormDraft, saveFormDraft,
|
|
sendInvoice,
|
|
applyCoupon, removeCoupon,
|
|
updateAttendees, sendAttendeeFormLink,
|
|
} = require('../controllers/registrationController');
|
|
const { protect, supervisor, staff, optionalAuth } = require('../middleware/authMiddleware');
|
|
const { scopeEvent, scopeList, scopeBody } = require('../utils/campusScope');
|
|
const { notOnSeasonPass } = require('../utils/seasonPass');
|
|
|
|
// Campus-scoped staff (utils/campusScope.js). Routes open to the registration's owner as well
|
|
// as to staff check staff against the registration's event, and let the owner through (ownerOk).
|
|
|
|
// Registration - auth optional when event doesn't require it
|
|
router.post('/', optionalAuth, createRegistration);
|
|
router.get('/myregistrations', protect, getUserRegistrations);
|
|
router.put('/:id/options', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), notOnSeasonPass, updateRegistrationOptions);
|
|
router.delete('/:id', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), cancelRegistration);
|
|
router.post('/:id/send-invoice', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), sendInvoice);
|
|
router.post('/:id/coupon', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), notOnSeasonPass, applyCoupon);
|
|
router.delete('/:id/coupon', protect, staff, scopeEvent({ resolve: 'registration' }), removeCoupon);
|
|
router.put('/:id/attendees', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), updateAttendees);
|
|
router.post('/:id/attendees/:attendeeId/send-form-link', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), sendAttendeeFormLink);
|
|
|
|
// Registration detail + forms — optionalAuth so guests can access with just the registrationId
|
|
router.get('/:id', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), getRegistrationById);
|
|
router.get('/:id/forms/draft', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), getFormDraft);
|
|
router.put('/:id/forms/draft', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), saveFormDraft);
|
|
router.post('/:id/forms/responses', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), submitFormResponses);
|
|
router.put('/:id/forms/responses', protect, supervisor, scopeEvent({ resolve: 'registration' }), replaceFormResponses);
|
|
|
|
// Admin/Staff routes
|
|
router.get('/', protect, staff, scopeList, getRegistrations);
|
|
router.put('/:id', protect, staff, scopeEvent({ resolve: 'registration' }), updateRegistrationStatus);
|
|
router.get('/event/:eventId', protect, staff, scopeEvent(), getRegistrationsByEvent);
|
|
router.post('/manual', protect, supervisor, scopeEvent({ from: req => req.body?.eventId }), createManualRegistration);
|
|
// Bulk actions (1.49.1): every ticked registration must be one this person may manage.
|
|
router.post('/bulk', protect, supervisor, scopeBody([['registrationIds', 'registration']], { orphan: 'deny' }), async (req, res) => {
|
|
try { res.json(await require('../utils/bulkRegistrations').runBulk(req, req.body || {})); } catch (e) { res.status(e.statusCode || 400).json({ message: e.message }); }
|
|
});
|
|
|
|
module.exports = router; |