Archived
"Copy" on each event card opens the event editor filled in from that event (campus, sessions, options, variants, early birds, sections, form, recipients, feedback questions, certificates, reminders). "New start" moves every date with it. Allocation groups and, for admins, planned costs are copied by POST /api/events/:id/copy-from. Registrations, coupons, attachments, kids check-in and volunteer roles are not copied. Roadmap: event series and cloning ships as 1.47.0-1.47.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
3.9 KiB
JavaScript
93 lines
3.9 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const {
|
|
createEvent,
|
|
copyEventSetupFrom,
|
|
getEvents,
|
|
getAllEvents,
|
|
getEventsAll,
|
|
getEventById,
|
|
getEventIcs,
|
|
updateEvent,
|
|
getEventNotifyRecipients,
|
|
updateEventNotifyRecipients,
|
|
deleteEvent,
|
|
createEventOption,
|
|
updateEventOption,
|
|
deleteEventOption,
|
|
createOptionVariant,
|
|
updateOptionVariant,
|
|
deleteOptionVariant,
|
|
listEventAttachments,
|
|
uploadEventAttachment,
|
|
deleteEventAttachment,
|
|
attachmentsStatus,
|
|
attachmentsSync,
|
|
emailEventAttendees,
|
|
scheduleEmailEventAttendees,
|
|
whatsappEventAttendees,
|
|
scheduleWhatsappEventAttendees,
|
|
getEventByAlias
|
|
} = require('../controllers/eventController');
|
|
const { protect, admin, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
|
const { scopeEvent, scopeBody, scopeList } = require('../utils/campusScope');
|
|
|
|
// Public routes
|
|
router.get('/', getEvents);
|
|
|
|
// Staff/supervisor/admin: all events including hidden, optional past/inactive filters
|
|
router.get('/all', protect, getEventsAll);
|
|
|
|
// Admin routes
|
|
router.get('/admin/all', protect, admin, getAllEvents);
|
|
router.get('/attachments/status', protect, admin, attachmentsStatus);
|
|
router.post('/attachments/sync', protect, admin, attachmentsSync);
|
|
|
|
// Public route for single event (keep after specific admin routes).
|
|
// optionalAuth populates req.user when a valid token is present so staff/supervisor/admin
|
|
// can still load inactive events (e.g. for cashup or editing) without being 404'd.
|
|
router.get('/:id', optionalAuth, getEventById);
|
|
router.get('/:id/ics', optionalAuth, getEventIcs);
|
|
router.get('/by-alias/:redirectUrl', getEventByAlias);
|
|
|
|
// Create/Update/Delete event
|
|
router.post('/', protect, supervisor, scopeList, createEvent);
|
|
router.route('/:id')
|
|
.put(protect, supervisor, scopeEvent({ need: 'manage' }), updateEvent)
|
|
.delete(protect, admin, deleteEvent);
|
|
|
|
// Clone: copy allocation groups (and costs, for admins) from the source event into a new copy.
|
|
router.post('/:id/copy-from', protect, supervisor, scopeEvent({ need: 'manage' }), scopeBody([['fromEventId', 'event']]), copyEventSetupFrom);
|
|
|
|
// Notification recipients: who gets registration/payment/daily-summary emails for this event
|
|
router.route('/:id/notify-recipients')
|
|
.get(protect, supervisor, scopeEvent(), getEventNotifyRecipients)
|
|
.put(protect, supervisor, scopeEvent({ need: 'manage' }), updateEventNotifyRecipients);
|
|
|
|
// Attachments routes
|
|
router.get('/:id/attachments', listEventAttachments); // public read (used by event detail page)
|
|
router.post('/:id/attachments', protect, supervisor, scopeEvent({ need: 'manage' }), ...uploadEventAttachment);
|
|
router.delete('/:eventId/attachments/:attachmentId', protect, supervisor, scopeEvent({ need: 'manage' }), deleteEventAttachment);
|
|
|
|
// Bulk email attendees
|
|
router.post('/:id/email-attendees', protect, supervisor, scopeEvent(), emailEventAttendees);
|
|
// Schedule bulk email to attendees
|
|
router.post('/:id/email-attendees/schedule', protect, supervisor, scopeEvent(), scheduleEmailEventAttendees);
|
|
// Bulk WhatsApp message to attendees
|
|
router.post('/:id/whatsapp-attendees', protect, supervisor, scopeEvent(), whatsappEventAttendees);
|
|
// Schedule bulk WhatsApp message to attendees
|
|
router.post('/:id/whatsapp-attendees/schedule', protect, supervisor, scopeEvent(), scheduleWhatsappEventAttendees);
|
|
|
|
// Event options routes
|
|
router.post('/:id/options', protect, supervisor, scopeEvent({ need: 'manage' }), createEventOption);
|
|
router.route('/options/:id')
|
|
.put(protect, supervisor, scopeEvent({ resolve: 'eventOption', need: 'manage' }), updateEventOption)
|
|
.delete(protect, admin, deleteEventOption);
|
|
|
|
// Option variant routes
|
|
router.post('/options/:id/variants', protect, supervisor, scopeEvent({ resolve: 'eventOption', need: 'manage' }), createOptionVariant);
|
|
router.route('/variants/:id')
|
|
.put(protect, supervisor, scopeEvent({ resolve: 'optionVariant', need: 'manage' }), updateOptionVariant)
|
|
.delete(protect, admin, deleteOptionVariant);
|
|
|
|
module.exports = router; |