From e3a9ab2ac1d8a28a7c7c323596cf80c20c9c15ca Mon Sep 17 00:00:00 2001 From: Meghashyam Bhandary Date: Fri, 1 Mar 2024 00:03:09 +0530 Subject: [PATCH] Added event registration start and end date --- src/controllers/events.js | 19 ++++++++++++++++--- src/models/Event.js | 4 +++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/controllers/events.js b/src/controllers/events.js index 0616a38..bbbdbb6 100644 --- a/src/controllers/events.js +++ b/src/controllers/events.js @@ -841,6 +841,8 @@ const get = async (req, res, next) => { endDate: event.endDate, slottable: event.slottable, faculty: event.faculty, + registrationStartDate: event.registrationStartDate, + registrationEndDate: event.registrationEndDate, }, }); }; @@ -872,6 +874,8 @@ const getAll = async (req, res) => { endDate: event.endDate, slottable: event.slottable, faculty: event.faculty, + registrationStartDate: event.registrationStartDate, + registrationEndDate: event.registrationEndDate, }; }); @@ -1289,7 +1293,10 @@ const create = async (req, res) => { startDate, endDate, slottable, - faculty } = req.body; + faculty, + registrationStartDate, + registrationEndDate, + } = req.body; let event = new EventModel({ name, @@ -1304,7 +1311,9 @@ const create = async (req, res) => { startDate, endDate, slottable, - faculty + faculty, + registrationStartDate, + registrationEndDate, }); await event.save(). @@ -1347,7 +1356,9 @@ const edit = async (req, res) => { endDate, slottable, // criteria, - faculty + faculty, + registrationStartDate, + registrationEndDate, } = req.body; let event = await EventModel.findById(req.params.event); @@ -1365,6 +1376,8 @@ const edit = async (req, res) => { event.endDate = endDate ? endDate : event.endDate; event.slottable = !!slottable; event.faculty = faculty != undefined ? faculty : event.faculty; + event.registrationStartDate = registrationStartDate ? registrationStartDate : event.registrationStartDate; + event.registrationEndDate = registrationEndDate ? registrationEndDate : event.registrationEndDate; //Seems like not required // if (criteria) { diff --git a/src/models/Event.js b/src/models/Event.js index bd29ec0..749ff24 100644 --- a/src/models/Event.js +++ b/src/models/Event.js @@ -1,7 +1,7 @@ const mongoose = require("mongoose"); const schema = { - rounds: [ mongoose.Schema.Types.ObjectId ], + rounds: [mongoose.Schema.Types.ObjectId], name: { type: String, required: true, @@ -27,6 +27,8 @@ const schema = { required: true, default: false, }, + registrationStartDate: Date, + registrationEndDate: Date }; const options = {