Skip to content

Commit d8c8531

Browse files
Revert "v1.2.2 Release"
1 parent c31ebdf commit d8c8531

File tree

9 files changed

+1069
-1236
lines changed

9 files changed

+1069
-1236
lines changed

controllers/ControllerController.js

Lines changed: 847 additions & 961 deletions
Large diffs are not rendered by default.

controllers/EventController.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ router.delete('/:slug/signup', getUser, async (req, res) => {
178178
return res.json(res.stdRes);
179179
});
180180

181-
router.delete('/:slug/mandelete/:cid', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async(req, res) => {
181+
router.delete('/:slug/mandelete/:cid', getUser, auth(['atm', 'datm', 'ec']), async(req, res) => {
182182
try {
183183
const signup = await Event.findOneAndUpdate({url: req.params.slug}, {
184184
$pull: {
@@ -211,7 +211,7 @@ router.delete('/:slug/mandelete/:cid', getUser, auth(['atm1', 'datm', 'ec', 'wm'
211211
return res.json(res.stdRes);
212212
});
213213

214-
router.put('/:slug/mansignup/:cid', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (req, res) => {
214+
router.put('/:slug/mansignup/:cid', getUser, auth(['atm', 'datm', 'ec']), async (req, res) => {
215215
try {
216216
const user = await User.findOne({cid: req.params.cid});
217217
if(user !== null) {
@@ -242,7 +242,7 @@ router.put('/:slug/mansignup/:cid', getUser, auth(['atm1', 'datm', 'ec', 'wm']),
242242
return res.json(res.stdRes);
243243
});
244244

245-
router.post('/', getUser, auth(['atm1', 'datm', 'ec', 'wm']), upload.single('banner'), async (req, res) => {
245+
router.post('/', getUser, auth(['atm', 'datm', 'ec']), upload.single('banner'), async (req, res) => {
246246
try {
247247
const url = req.body.name.replace(/\s+/g, '-').toLowerCase().replace(/^-+|-+(?=-|$)/g, '').replace(/[^a-zA-Z0-9-_]/g, '') + '-' + Date.now().toString().slice(-5);
248248
const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'];
@@ -296,7 +296,7 @@ router.post('/', getUser, auth(['atm1', 'datm', 'ec', 'wm']), upload.single('ban
296296
return res.json(res.stdRes);
297297
});
298298

299-
router.put('/:slug', getUser, auth(['atm1', 'datm', 'ec', 'wm']), upload.single('banner'), async (req, res) => {
299+
router.put('/:slug', getUser, auth(['atm', 'datm', 'ec']), upload.single('banner'), async (req, res) => {
300300
try {
301301
const event = await Event.findOne({url: req.params.slug});
302302
const {name, description, startTime, endTime, positions} = req.body;
@@ -408,7 +408,7 @@ router.put('/:slug', getUser, auth(['atm1', 'datm', 'ec', 'wm']), upload.single(
408408
return res.json(res.stdRes);
409409
});
410410

411-
router.delete('/:slug', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (req, res) => {
411+
router.delete('/:slug', getUser, auth(['atm', 'datm', 'ec']), async (req, res) => {
412412
try {
413413
const deleteEvent = await Event.findOne({url: req.params.slug});
414414
await deleteEvent.delete();
@@ -448,7 +448,7 @@ router.delete('/:slug', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (req,
448448
// return res.json(res.stdRes);
449449
// });
450450

451-
router.put('/:slug/assign', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (req, res) => {
451+
router.put('/:slug/assign', getUser, auth(['atm', 'datm', 'ec']), async (req, res) => {
452452
try {
453453
const {position, cid} = req.body;
454454

@@ -484,7 +484,7 @@ router.put('/:slug/assign', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (
484484
return res.json(res.stdRes);
485485
});
486486

487-
router.put('/:slug/notify', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (req, res) => {
487+
router.put('/:slug/notify', getUser, auth(['atm', 'datm', 'ec']), async (req, res) => {
488488
try {
489489
await Event.updateOne({url: req.params.slug}, {
490490
$set: {
@@ -524,7 +524,7 @@ router.put('/:slug/notify', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (
524524
return res.json(res.stdRes);
525525
});
526526

527-
router.put('/:slug/close', getUser, auth(['atm1', 'datm', 'ec', 'wm']), async (req, res) => {
527+
router.put('/:slug/close', getUser, auth(['atm', 'datm', 'ec']), async (req, res) => {
528528
try {
529529
await Event.updateOne({url: req.params.slug}, {
530530
$set: {

controllers/FeedbackController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Notification from '../models/Notification.js';
66
import getUser from '../middleware/getUser.js';
77
import auth from '../middleware/auth.js';
88

9-
router.get('/', getUser, auth(['atm1', 'datm', 'ta', 'ec','wm']), async (req, res) => { // All feedback
9+
router.get('/', getUser, auth(['atm', 'datm', 'ta', 'ec']), async (req, res) => { // All feedback
1010
try {
1111
const page = +req.query.page || 1;
1212
const limit = +req.query.limit || 20;
@@ -85,7 +85,7 @@ router.get('/controllers', async ({res}) => { // Controller list on feedback pag
8585
return res.json(res.stdRes);
8686
});
8787

88-
router.get('/unapproved', getUser, auth(['atm1', 'datm', 'ta', 'ec', 'wm']), async ({res}) => { // Get all unapproved feedback
88+
router.get('/unapproved', getUser, auth(['atm', 'datm', 'ta', 'ec']), async ({res}) => { // Get all unapproved feedback
8989
try {
9090
const feedback = await Feedback.find({deletedAt: null, approved: false}).populate('controller', 'fname lname cid').sort({createdAt: 'desc'}).lean();
9191
res.stdRes.data = feedback;
@@ -96,7 +96,7 @@ router.get('/unapproved', getUser, auth(['atm1', 'datm', 'ta', 'ec', 'wm']), asy
9696
return res.json(res.stdRes);
9797
});
9898

99-
router.put('/approve/:id', getUser, auth(['atm1', 'datm', 'ta']), async (req, res) => { // Approve feedback
99+
router.put('/approve/:id', getUser, auth(['atm', 'datm', 'ta']), async (req, res) => { // Approve feedback
100100
try {
101101
const approved = await Feedback.findOneAndUpdate({_id: req.params.id}, {
102102
approved: true
@@ -123,7 +123,7 @@ router.put('/approve/:id', getUser, auth(['atm1', 'datm', 'ta']), async (req, re
123123
return res.json(res.stdRes);
124124
});
125125

126-
router.put('/reject/:id', getUser, auth(['atm1', 'datm', 'ta']), async (req, res) => { // Reject feedback
126+
router.put('/reject/:id', getUser, auth(['atm', 'datm', 'ta']), async (req, res) => { // Reject feedback
127127
try {
128128
const feedback = await Feedback.findOne({_id: req.params.id});
129129
await feedback.delete();

controllers/FileController.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ router.get('/downloads/:id', async (req, res) => {
5050
return res.json(res.stdRes);
5151
});
5252

53-
router.post('/downloads', getUser, auth(['atm1', 'datm', 'ta', 'fe']), upload.single('download'), async (req, res) => {
53+
router.post('/downloads', getUser, auth(['atm', 'datm', 'ta', 'fe']), upload.single('download'), async (req, res) => {
5454
try {
5555
if(!req.body.category) {
5656
throw {
@@ -95,7 +95,7 @@ router.post('/downloads', getUser, auth(['atm1', 'datm', 'ta', 'fe']), upload.si
9595
return res.json(res.stdRes);
9696
});
9797

98-
router.put('/downloads/:id', upload.single('download'), getUser, auth(['atm1', 'datm', 'ta', 'fe']), async (req, res) => {
98+
router.put('/downloads/:id', upload.single('download'), getUser, auth(['atm', 'datm', 'ta', 'fe']), async (req, res) => {
9999
try {
100100
if(!req.file) { // no updated file provided
101101
await Downloads.findByIdAndUpdate(req.params.id, {
@@ -140,7 +140,7 @@ router.put('/downloads/:id', upload.single('download'), getUser, auth(['atm1', '
140140
return res.json(res.stdRes);
141141
});
142142

143-
router.delete('/downloads/:id', getUser, auth(['atm1', 'datm', 'ta', 'fe']), async (req, res) => {
143+
router.delete('/downloads/:id', getUser, auth(['atm', 'datm', 'ta', 'fe']), async (req, res) => {
144144
try {
145145
const download = await Downloads.findByIdAndDelete(req.params.id).lean();
146146
await req.app.dossier.create({
@@ -181,7 +181,7 @@ router.get('/documents/:slug', async (req, res) => {
181181
return res.json(res.stdRes);
182182
});
183183

184-
router.post('/documents', getUser, auth(['atm1', 'datm', 'ta', 'fe']), upload.single('download'), async (req, res) => {
184+
router.post('/documents', getUser, auth(['atm', 'datm', 'ta', 'fe']), upload.single('download'), async (req, res) => {
185185
try {
186186
const {name, category, description, content, type} = req.body;
187187
if(!category) {
@@ -252,7 +252,7 @@ router.post('/documents', getUser, auth(['atm1', 'datm', 'ta', 'fe']), upload.si
252252
return res.json(res.stdRes);
253253
});
254254

255-
router.put('/documents/:slug', upload.single('download'), getUser, auth(['atm1', 'datm', 'ta', 'fe']), async (req, res) => {
255+
router.put('/documents/:slug', upload.single('download'), getUser, auth(['atm', 'datm', 'ta', 'fe']), async (req, res) => {
256256
try {
257257
const document = await Document.findOne({slug: req.params.slug});
258258
const {name, category, description, content, type} = req.body;
@@ -318,7 +318,7 @@ router.put('/documents/:slug', upload.single('download'), getUser, auth(['atm1',
318318
return res.json(res.stdRes);
319319
})
320320

321-
router.delete('/documents/:id', getUser, auth(['atm1', 'datm', 'ta', 'fe']), async (req, res) => {
321+
router.delete('/documents/:id', getUser, auth(['atm', 'datm', 'ta', 'fe']), async (req, res) => {
322322
try {
323323
const doc = await Document.findByIdAndDelete(req.params.id);
324324
await req.app.dossier.create({

controllers/NewsController.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ router.get('/', async (req, res) => {
1818
return res.json(res.stdRes);
1919
});
2020

21-
router.post('/', getUser, auth(['atm1', 'datm', 'ta', 'ec', 'fe', 'wm']), async (req, res) => {
21+
router.post('/', getUser, auth(['atm', 'datm', 'ta', 'ec', 'fe', 'wm']), async (req, res) => {
2222
try {
2323
if(!req.body || !req.body.title || !req.body.content) {
2424
throw {
@@ -74,7 +74,7 @@ router.get('/:slug', async (req, res) =>{
7474
return res.json(res.stdRes);
7575
});
7676

77-
router.put('/:slug', getUser, auth(['atm1', 'datm', 'ta', 'ec', 'fe', 'wm']), async (req, res) => {
77+
router.put('/:slug', getUser, auth(['atm', 'datm', 'ta', 'ec', 'fe', 'wm']), async (req, res) => {
7878
try {
7979
const {title, content} = req.body;
8080
const newsItem = await News.findOne({uriSlug: req.params.slug});
@@ -98,7 +98,7 @@ router.put('/:slug', getUser, auth(['atm1', 'datm', 'ta', 'ec', 'fe', 'wm']), as
9898
return res.json(res.stdRes);
9999
});
100100

101-
router.delete('/:slug', getUser, auth(['atm1', 'datm', 'ta', 'ec', 'fe', 'wm']), async (req, res) =>{
101+
router.delete('/:slug', getUser, auth(['atm', 'datm', 'ta', 'ec', 'fe', 'wm']), async (req, res) =>{
102102
try {
103103
const newsItem = await News.findOne({uriSlug: req.params.slug});
104104
const status = await newsItem.delete();

controllers/StatsController.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { DateTime as L } from 'luxon';
1616
const months = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
1717
const ratings = ["Unknown", "OBS", "S1", "S2", "S3", "C1", "C2", "C3", "I1", "I2", "I3", "SUP", "ADM"];
1818

19-
router.get('/admin', getUser, auth(['atm1', 'datm', 'ta', 'fe', 'ec', 'wm']), async (req, res) => {
19+
router.get('/admin', getUser, auth(['atm', 'datm', 'ta', 'fe', 'ec', 'wm']), async (req, res) => {
2020
try {
2121
const d = new Date();
2222
const thisMonth = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1));
@@ -117,7 +117,7 @@ router.get('/admin', getUser, auth(['atm1', 'datm', 'ta', 'fe', 'ec', 'wm']), as
117117
return res.json(res.stdRes);
118118
})
119119

120-
router.get('/ins', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
120+
router.get('/ins', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
121121
try {
122122
let lastTraining = await TrainingSession.aggregate([
123123
{$group: {
@@ -170,7 +170,7 @@ router.get('/ins', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async (r
170170
return res.json(res.stdRes);
171171
})
172172

173-
router.get('/activity', getUser, auth(['atm1', 'datm', 'ta', 'wm']), async (req, res) => {
173+
router.get('/activity', getUser, auth(['atm', 'datm', 'ta', 'wm']), async (req, res) => {
174174
try {
175175
const today = L.utc();
176176
const chkDate = today.minus({days: 91});

controllers/TrainingController.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ router.get('/milestones', getUser, async (req, res) => {
129129
return res.json(res.stdRes);
130130
});
131131

132-
router.get('/request/open', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
132+
router.get('/request/open', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
133133
try {
134134
const days = +req.query.period || 21; // days from start of CURRENT week
135135
const d = new Date(Date.now()),
@@ -155,7 +155,7 @@ router.get('/request/open', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']),
155155
return res.json(res.stdRes);
156156
});
157157

158-
router.post('/request/take/:id', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
158+
router.post('/request/take/:id', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
159159
try {
160160
if(new Date(req.body.startTime) >= new Date(req.body.endTime)) {
161161
throw {
@@ -206,7 +206,7 @@ router.post('/request/take/:id', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mt
206206
return res.json(res.stdRes);
207207
});
208208

209-
router.delete('/request/:id', getUser, auth(['atm1', 'datm', 'ta']), async (req, res) => {
209+
router.delete('/request/:id', getUser, auth(['atm', 'datm', 'ta']), async (req, res) => {
210210
try {
211211
const request = await TrainingRequest.findById(req.params.id);
212212
request.delete();
@@ -224,7 +224,7 @@ router.delete('/request/:id', getUser, auth(['atm1', 'datm', 'ta']), async (req,
224224
return res.json(res.stdRes);
225225
});
226226

227-
router.get('/request/:date', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
227+
router.get('/request/:date', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
228228
try {
229229
const d = new Date(`${req.params.date.slice(0,4)}-${req.params.date.slice(4,6)}-${req.params.date.slice(6,8)}`);
230230
const dayAfter = new Date(d);
@@ -248,7 +248,7 @@ router.get('/request/:date', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr'])
248248
return res.json(res.stdRes);
249249
});
250250

251-
router.get('/session/open', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
251+
router.get('/session/open', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async (req, res) => {
252252
try {
253253
const sessions = await TrainingSession.find({
254254
instructorCid: res.user.cid,
@@ -266,7 +266,7 @@ router.get('/session/open', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']),
266266

267267
router.get('/session/:id', getUser, async(req, res) => {
268268
try {
269-
const isIns = ['ta', 'ins', 'mtr', 'atm1', 'datm'].some(r => res.user.roleCodes.includes(r));
269+
const isIns = ['ta', 'ins', 'mtr', 'atm', 'datm'].some(r => res.user.roleCodes.includes(r));
270270

271271
if(isIns) {
272272
const session = await TrainingSession.findById(
@@ -303,7 +303,7 @@ router.get('/session/:id', getUser, async(req, res) => {
303303
return res.json(res.stdRes);
304304
});
305305

306-
router.get('/sessions', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
306+
router.get('/sessions', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
307307
try {
308308
const page = +req.query.page || 1;
309309
const limit = +req.query.limit || 20;
@@ -404,7 +404,7 @@ router.get('/sessions/past', getUser, async (req, res) => {
404404
return res.json(res.stdRes);
405405
});
406406

407-
router.get('/sessions/:cid', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
407+
router.get('/sessions/:cid', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
408408
try {
409409
const controller = await User.findOne({cid: req.params.cid}).select('fname lname').lean();
410410
if(!controller) {
@@ -441,7 +441,7 @@ router.get('/sessions/:cid', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr'])
441441
return res.json(res.stdRes);
442442
});
443443

444-
router.put('/session/save/:id', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
444+
router.put('/session/save/:id', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
445445
try {
446446
await TrainingSession.findByIdAndUpdate(req.params.id, req.body);
447447
} catch(e) {
@@ -452,7 +452,7 @@ router.put('/session/save/:id', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr
452452
return res.json(res.stdRes);
453453
});
454454

455-
router.put('/session/submit/:id', getUser, auth(['atm1', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
455+
router.put('/session/submit/:id', getUser, auth(['atm', 'datm', 'ta', 'ins', 'mtr']), async(req, res) => {
456456
try {
457457
if(req.body.position === '' || req.body.progress === null || req.body.movements === null || req.body.location === null || req.body.ots === null || req.body.studentNotes === null || (req.body.studentNotes && req.body.studentNotes.length > 3000) || (req.body.insNotes && req.body.insNotes.length > 3000)) {
458458
throw {

0 commit comments

Comments
 (0)