Skip to content

Commit 60744fe

Browse files
authored
Change confirmation route to allow user to switch to cancelled (#293)
* Change confirmation route to allow user to switch to cancelled * Fix test
1 parent 3e17a45 commit 60744fe

File tree

7 files changed

+56
-56
lines changed

7 files changed

+56
-56
lines changed

docs/api/api_data.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ define({
12501250
},
12511251
{
12521252
"type": "get",
1253-
"url": "/hacker/email/:email",
1253+
"url": "/hacker/:id",
12541254
"title": "get a hacker's information",
12551255
"name": "getHacker",
12561256
"group": "Hacker",
@@ -1261,8 +1261,8 @@ define({
12611261
"group": "param",
12621262
"type": "String",
12631263
"optional": false,
1264-
"field": "email",
1265-
"description": "<p>a hacker's unique email</p>"
1264+
"field": "id",
1265+
"description": "<p>a hacker's unique mongoID</p>"
12661266
}]
12671267
}
12681268
},
@@ -1317,12 +1317,12 @@ define({
13171317
"filename": "routes/api/hacker.js",
13181318
"groupTitle": "Hacker",
13191319
"sampleRequest": [{
1320-
"url": "https://api.mchacks.ca/api/hacker/email/:email"
1320+
"url": "https://api.mchacks.ca/api/hacker/:id"
13211321
}]
13221322
},
13231323
{
13241324
"type": "get",
1325-
"url": "/hacker/:id",
1325+
"url": "/hacker/email/:email",
13261326
"title": "get a hacker's information",
13271327
"name": "getHacker",
13281328
"group": "Hacker",
@@ -1333,8 +1333,8 @@ define({
13331333
"group": "param",
13341334
"type": "String",
13351335
"optional": false,
1336-
"field": "id",
1337-
"description": "<p>a hacker's unique mongoID</p>"
1336+
"field": "email",
1337+
"description": "<p>a hacker's unique email</p>"
13381338
}]
13391339
}
13401340
},
@@ -1389,7 +1389,7 @@ define({
13891389
"filename": "routes/api/hacker.js",
13901390
"groupTitle": "Hacker",
13911391
"sampleRequest": [{
1392-
"url": "https://api.mchacks.ca/api/hacker/:id"
1392+
"url": "https://api.mchacks.ca/api/hacker/email/:email"
13931393
}]
13941394
},
13951395
{
@@ -1628,7 +1628,7 @@ define({
16281628
{
16291629
"type": "patch",
16301630
"url": "/hacker/confirmation/:id",
1631-
"title": "Allows confirmation of hacker attendence if they are accepted. Also allows change from 'confirmed' back to 'accepted'",
1631+
"title": "Allows confirmation of hacker attendence if they are accepted. Also allows change from 'confirmed' to 'cancelled'.",
16321632
"name": "patchHackerConfirmed",
16331633
"group": "Hacker",
16341634
"version": "0.0.9",
@@ -1639,7 +1639,7 @@ define({
16391639
"type": "string",
16401640
"optional": true,
16411641
"field": "status",
1642-
"description": "<p>The new status of the hacker. &quot;Accepted&quot; or &quot;Confirmed&quot;</p>"
1642+
"description": "<p>The new status of the hacker. &quot;Accepted&quot;, &quot;Confirmed&quot;, or &quot;Cancelled&quot;</p>"
16431643
}]
16441644
}
16451645
},

docs/api/api_data.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@
12491249
},
12501250
{
12511251
"type": "get",
1252-
"url": "/hacker/email/:email",
1252+
"url": "/hacker/:id",
12531253
"title": "get a hacker's information",
12541254
"name": "getHacker",
12551255
"group": "Hacker",
@@ -1260,8 +1260,8 @@
12601260
"group": "param",
12611261
"type": "String",
12621262
"optional": false,
1263-
"field": "email",
1264-
"description": "<p>a hacker's unique email</p>"
1263+
"field": "id",
1264+
"description": "<p>a hacker's unique mongoID</p>"
12651265
}]
12661266
}
12671267
},
@@ -1316,12 +1316,12 @@
13161316
"filename": "routes/api/hacker.js",
13171317
"groupTitle": "Hacker",
13181318
"sampleRequest": [{
1319-
"url": "https://api.mchacks.ca/api/hacker/email/:email"
1319+
"url": "https://api.mchacks.ca/api/hacker/:id"
13201320
}]
13211321
},
13221322
{
13231323
"type": "get",
1324-
"url": "/hacker/:id",
1324+
"url": "/hacker/email/:email",
13251325
"title": "get a hacker's information",
13261326
"name": "getHacker",
13271327
"group": "Hacker",
@@ -1332,8 +1332,8 @@
13321332
"group": "param",
13331333
"type": "String",
13341334
"optional": false,
1335-
"field": "id",
1336-
"description": "<p>a hacker's unique mongoID</p>"
1335+
"field": "email",
1336+
"description": "<p>a hacker's unique email</p>"
13371337
}]
13381338
}
13391339
},
@@ -1388,7 +1388,7 @@
13881388
"filename": "routes/api/hacker.js",
13891389
"groupTitle": "Hacker",
13901390
"sampleRequest": [{
1391-
"url": "https://api.mchacks.ca/api/hacker/:id"
1391+
"url": "https://api.mchacks.ca/api/hacker/email/:email"
13921392
}]
13931393
},
13941394
{
@@ -1627,7 +1627,7 @@
16271627
{
16281628
"type": "patch",
16291629
"url": "/hacker/confirmation/:id",
1630-
"title": "Allows confirmation of hacker attendence if they are accepted. Also allows change from 'confirmed' back to 'accepted'",
1630+
"title": "Allows confirmation of hacker attendence if they are accepted. Also allows change from 'confirmed' to 'cancelled'.",
16311631
"name": "patchHackerConfirmed",
16321632
"group": "Hacker",
16331633
"version": "0.0.9",
@@ -1638,7 +1638,7 @@
16381638
"type": "string",
16391639
"optional": true,
16401640
"field": "status",
1641-
"description": "<p>The new status of the hacker. &quot;Accepted&quot; or &quot;Confirmed&quot;</p>"
1641+
"description": "<p>The new status of the hacker. &quot;Accepted&quot;, &quot;Confirmed&quot;, or &quot;Cancelled&quot;</p>"
16421642
}]
16431643
}
16441644
},

docs/api/api_project.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
define({
2-
"name": "hackerAPI",
3-
"version": "0.0.8",
4-
"description": "Documentation for the API used for mchacks",
5-
"defaultVersion": "0.0.8",
6-
"title": "hackerAPI documentation",
7-
"url": "https://api.mchacks.ca/api",
8-
"sampleUrl": "https://api.mchacks.ca/api",
9-
"apidoc": "0.3.0",
10-
"generator": {
11-
"name": "apidoc",
12-
"time": "2019-01-10T23:24:21.462Z",
13-
"url": "http://apidocjs.com",
14-
"version": "0.17.7"
15-
}
1+
define({
2+
"name": "hackerAPI",
3+
"version": "0.0.8",
4+
"description": "Documentation for the API used for mchacks",
5+
"defaultVersion": "0.0.8",
6+
"title": "hackerAPI documentation",
7+
"url": "https://api.mchacks.ca/api",
8+
"sampleUrl": "https://api.mchacks.ca/api",
9+
"apidoc": "0.3.0",
10+
"generator": {
11+
"name": "apidoc",
12+
"time": "2019-01-14T00:33:25.620Z",
13+
"url": "http://apidocjs.com",
14+
"version": "0.17.7"
15+
}
1616
});

docs/api/api_project.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
{
2-
"name": "hackerAPI",
3-
"version": "0.0.8",
4-
"description": "Documentation for the API used for mchacks",
5-
"defaultVersion": "0.0.8",
6-
"title": "hackerAPI documentation",
7-
"url": "https://api.mchacks.ca/api",
8-
"sampleUrl": "https://api.mchacks.ca/api",
9-
"apidoc": "0.3.0",
10-
"generator": {
11-
"name": "apidoc",
12-
"time": "2019-01-10T23:24:21.462Z",
13-
"url": "http://apidocjs.com",
14-
"version": "0.17.7"
15-
}
1+
{
2+
"name": "hackerAPI",
3+
"version": "0.0.8",
4+
"description": "Documentation for the API used for mchacks",
5+
"defaultVersion": "0.0.8",
6+
"title": "hackerAPI documentation",
7+
"url": "https://api.mchacks.ca/api",
8+
"sampleUrl": "https://api.mchacks.ca/api",
9+
"apidoc": "0.3.0",
10+
"generator": {
11+
"name": "apidoc",
12+
"time": "2019-01-14T00:33:25.620Z",
13+
"url": "http://apidocjs.com",
14+
"version": "0.17.7"
15+
}
1616
}

middlewares/hacker.middleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function parseCheckIn(req, res, next) {
9898
* @param {(err?)=>void} next
9999
* @return {void}
100100
* @description
101-
* Changes req.body.status to confirmed or accepted depending on whether req.body.confirm is true or false respectively.
101+
* Changes req.body.status to confirmed or cancelled depending on whether req.body.confirm is true or false respectively.
102102
* Deletes req.body.confirm afterwards
103103
*/
104104
function parseConfirmation(req, res, next) {
@@ -107,7 +107,7 @@ function parseConfirmation(req, res, next) {
107107
if (confirm) {
108108
req.body.status = Constants.General.HACKER_STATUS_CONFIRMED;
109109
} else {
110-
req.body.status = Constants.General.HACKER_STATUS_ACCEPTED;
110+
req.body.status = Constants.General.HACKER_STATUS_CANCELLED;
111111
}
112112

113113
delete req.body.confirm;

routes/api/hacker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,12 @@ module.exports = {
550550

551551
/**
552552
* @api {patch} /hacker/confirmation/:id
553-
* Allows confirmation of hacker attendence if they are accepted. Also allows change from 'confirmed' back to 'accepted'
553+
* Allows confirmation of hacker attendence if they are accepted. Also allows change from 'confirmed' to 'cancelled'.
554554
* @apiName patchHackerConfirmed
555555
* @apiGroup Hacker
556556
* @apiVersion 0.0.9
557557
*
558-
* @apiParam (body) {string} [status] The new status of the hacker. "Accepted" or "Confirmed"
558+
* @apiParam (body) {string} [status] The new status of the hacker. "Accepted", "Confirmed", or "Cancelled"
559559
* @apiSuccess {string} message Success message
560560
* @apiSuccess {object} data Hacker object
561561
* @apiSuccessExample {object} Success-Response:
@@ -577,7 +577,7 @@ module.exports = {
577577
Middleware.parseBody.middleware,
578578
Middleware.Hacker.parsePatch,
579579

580-
Middleware.Hacker.checkStatus([CONSTANTS.HACKER_STATUS_ACCEPTED, CONSTANTS.HACKER_STATUS_CONFIRMED]),
580+
Middleware.Hacker.checkStatus([CONSTANTS.HACKER_STATUS_ACCEPTED, CONSTANTS.HACKER_STATUS_CONFIRMED, CONSTANTS.HACKER_STATUS_CANCELLED]),
581581

582582
Middleware.Hacker.parseConfirmation,
583583
Middleware.Hacker.updateHacker,

tests/hacker.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ describe("PATCH update one hacker", function () {
735735
res.body.message.should.equal(Constants.Success.HACKER_UPDATE);
736736
res.body.should.have.property("data");
737737
chai.assert.equal(JSON.stringify(res.body.data), JSON.stringify({
738-
status: Constants.General.HACKER_STATUS_ACCEPTED
738+
status: Constants.General.HACKER_STATUS_CANCELLED
739739
}));
740740

741741
done();

0 commit comments

Comments
 (0)