Copy an event (1.47.0)
"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>
This commit is contained in:
@@ -102,6 +102,20 @@ async function saveSchedule(tx, eventId, body) {
|
||||
return changes;
|
||||
}
|
||||
|
||||
// @desc Copy allocation groups (and, for admins, planned costs) from another event into a new copy
|
||||
// @route POST /api/events/:id/copy-from
|
||||
// @access Private/Supervisor
|
||||
const copyEventSetupFrom = async (req, res) => {
|
||||
try {
|
||||
const fromEventId = req.body?.fromEventId;
|
||||
if (!fromEventId) return res.status(400).json({ message: 'fromEventId is required' });
|
||||
const copied = await require('../utils/eventClone').copyEventSetup(String(fromEventId), req.params.id, { withCosts: req.user?.role === 'admin' });
|
||||
res.json(copied);
|
||||
} catch (error) {
|
||||
res.status(error.statusCode || 400).json({ message: error.message });
|
||||
}
|
||||
};
|
||||
|
||||
// Helper to convert stored picture path/URL to an absolute, externally reachable URL based on the incoming request
|
||||
function toAbsoluteUrl(req, url) {
|
||||
if (!url) return url;
|
||||
@@ -196,7 +210,7 @@ const createEvent = async (req, res) => {
|
||||
action: 'event_created',
|
||||
targetType: 'Event',
|
||||
targetId: createdEvent.id,
|
||||
metadata: { title: createdEvent.title },
|
||||
metadata: { title: createdEvent.title, ...(req.body.clonedFromId ? { clonedFromId: String(req.body.clonedFromId) } : {}) },
|
||||
ip: getClientIp(req),
|
||||
});
|
||||
|
||||
@@ -2156,6 +2170,7 @@ const getEventByAlias = async (req, res) => {
|
||||
|
||||
module.exports = {
|
||||
createEvent,
|
||||
copyEventSetupFrom,
|
||||
getEvents,
|
||||
getAllEvents,
|
||||
getEventsAll,
|
||||
|
||||
Reference in New Issue
Block a user