summaryrefslogtreecommitdiff
path: root/routes.js
diff options
context:
space:
mode:
authorlowercasename <raphaelkabo@gmail.com>2019-09-14 10:08:09 +0100
committerlowercasename <raphaelkabo@gmail.com>2019-09-14 10:08:09 +0100
commit9d3da3563ce13d54673cfa3468911caeb4836741 (patch)
treeb5a751b303552d68e1e406ea4ae110892f235153 /routes.js
parent3b15d58ef86c041b44523462460fb3d70352ab1b (diff)
Functionality to limit number of attendees
Diffstat (limited to 'routes.js')
-rwxr-xr-xroutes.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/routes.js b/routes.js
index fde1b86..4e665ba 100755
--- a/routes.js
+++ b/routes.js
@@ -244,6 +244,13 @@ router.get('/:eventID', (req, res) => {
}
}
let eventAttendees = event.attendees.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0));
+ let spotsRemaining, noMoreSpots;
+ if (event.maxAttendees) {
+ spotsRemaining = event.maxAttendees - eventAttendees.length;
+ if (spotsRemaining <= 0) {
+ noMoreSpots = true;
+ }
+ }
let metadata = {
title: event.name,
description: marked(event.description, { renderer: render_plain()}).split(" ").splice(0,40).join(" ").trim(),
@@ -256,6 +263,8 @@ router.get('/:eventID', (req, res) => {
escapedName: escapedName,
eventData: event,
eventAttendees: eventAttendees,
+ spotsRemaining: spotsRemaining,
+ noMoreSpots: noMoreSpots,
eventStartISO: eventStartISO,
eventEndISO: eventEndISO,
parsedLocation: parsedLocation,
@@ -334,6 +343,7 @@ router.post('/newevent', (req, res) => {
usersCanAttend: req.body.joinCheckbox ? true : false,
showUsersList: req.body.guestlistCheckbox ? true : false,
usersCanComment: req.body.interactionCheckbox ? true : false,
+ maxAttendees: req.body.maxAttendees,
firstLoad: true
});
event.save()
@@ -470,7 +480,9 @@ router.post('/editevent/:eventID/:editToken', (req, res) => {
image: eventImageFilename,
usersCanAttend: req.body.joinCheckbox ? true : false,
showUsersList: req.body.guestlistCheckbox ? true : false,
- usersCanComment: req.body.interactionCheckbox ? true : false
+ usersCanComment: req.body.interactionCheckbox ? true : false,
+ maxAttendees: req.body.maxAttendeesCheckbox ? req.body.maxAttendees : null,
+
}
Event.findOneAndUpdate({id: req.params.eventID}, updatedEvent, function(err, raw) {
if (err) {