From 507a6a712f1715496726eaba99671637409425a2 Mon Sep 17 00:00:00 2001 From: Pierre Theo Klein Date: Fri, 4 Jan 2019 20:00:39 +0100 Subject: [PATCH 1/2] Make more items editable --- middlewares/validators/hacker.validator.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/middlewares/validators/hacker.validator.js b/middlewares/validators/hacker.validator.js index 56c4aafd..62cf5750 100644 --- a/middlewares/validators/hacker.validator.js +++ b/middlewares/validators/hacker.validator.js @@ -21,13 +21,15 @@ module.exports = { VALIDATOR.booleanValidator("body", "confirm", false), ], - // untested updateHackerValidator: [ VALIDATOR.nameValidator("body", "school", true), VALIDATOR.nameValidator("body", "degree", true), VALIDATOR.nameValidator("body", "gender", true), + VALIDATOR.booleanValidator("body", "needsBus", true), VALIDATOR.applicationValidator("body", "application", true), - VALIDATOR.booleanValidator("body", "needsBus", true) + VALIDATOR.alphaArrayValidator("body", "ethnicity", true), + VALIDATOR.nameValidator("body", "major", true), + VALIDATOR.integerValidator("body", "graduationYear", true, 2019, 2030), ], updateStatusValidator: [ VALIDATOR.enumValidator("body", "status", Constants.HACKER_STATUSES, false), From 7a235423db8a3fc3a0c4e05f0cde2d932b599bfd Mon Sep 17 00:00:00 2001 From: Pierre Theo Klein Date: Fri, 4 Jan 2019 20:05:46 +0100 Subject: [PATCH 2/2] Update docs --- docs/api/api_data.js | 21 +++++++++++++++++++++ docs/api/api_data.json | 21 +++++++++++++++++++++ docs/api/api_project.js | 30 +++++++++++++++--------------- docs/api/api_project.json | 30 +++++++++++++++--------------- docs/api/locales/cs.js | 25 +++++++++++++++++++++++++ docs/api/locales/locale.js | 15 ++++++++------- routes/api/hacker.js | 3 +++ 7 files changed, 108 insertions(+), 37 deletions(-) create mode 100644 docs/api/locales/cs.js diff --git a/docs/api/api_data.js b/docs/api/api_data.js index a68b7fad..e7ca521a 100644 --- a/docs/api/api_data.js +++ b/docs/api/api_data.js @@ -1423,6 +1423,27 @@ define({ "field": "needsBus", "description": "

Whether the hacker requires a bus for transportation

" }, + { + "group": "body", + "type": "String[]", + "optional": true, + "field": "ethnicity", + "description": "

the ethnicities of the hacker

" + }, + { + "group": "body", + "type": "String", + "optional": true, + "field": "major", + "description": "

the major of the hacker

" + }, + { + "group": "body", + "type": "Number", + "optional": true, + "field": "graduationYear", + "description": "

the graduation year of the hacker

" + }, { "group": "body", "type": "Json", diff --git a/docs/api/api_data.json b/docs/api/api_data.json index dbf4070b..669d5211 100644 --- a/docs/api/api_data.json +++ b/docs/api/api_data.json @@ -1422,6 +1422,27 @@ "field": "needsBus", "description": "

Whether the hacker requires a bus for transportation

" }, + { + "group": "body", + "type": "String[]", + "optional": true, + "field": "ethnicity", + "description": "

the ethnicities of the hacker

" + }, + { + "group": "body", + "type": "String", + "optional": true, + "field": "major", + "description": "

the major of the hacker

" + }, + { + "group": "body", + "type": "Number", + "optional": true, + "field": "graduationYear", + "description": "

the graduation year of the hacker

" + }, { "group": "body", "type": "Json", diff --git a/docs/api/api_project.js b/docs/api/api_project.js index 280527e1..15bcf7f8 100644 --- a/docs/api/api_project.js +++ b/docs/api/api_project.js @@ -1,16 +1,16 @@ -define({ - "name": "hackerAPI", - "version": "0.0.8", - "description": "Documentation for the API used for mchacks", - "defaultVersion": "0.0.8", - "title": "hackerAPI documentation", - "url": "https://api.mchacks.ca/api", - "sampleUrl": "https://api.mchacks.ca/api", - "apidoc": "0.3.0", - "generator": { - "name": "apidoc", - "time": "2018-12-20T06:25:49.908Z", - "url": "http://apidocjs.com", - "version": "0.17.6" - } +define({ + "name": "hackerAPI", + "version": "0.0.8", + "description": "Documentation for the API used for mchacks", + "defaultVersion": "0.0.8", + "title": "hackerAPI documentation", + "url": "https://api.mchacks.ca/api", + "sampleUrl": "https://api.mchacks.ca/api", + "apidoc": "0.3.0", + "generator": { + "name": "apidoc", + "time": "2019-01-04T19:05:11.619Z", + "url": "http://apidocjs.com", + "version": "0.17.7" + } }); \ No newline at end of file diff --git a/docs/api/api_project.json b/docs/api/api_project.json index 7d7d0bdd..ac1f7ed1 100644 --- a/docs/api/api_project.json +++ b/docs/api/api_project.json @@ -1,16 +1,16 @@ -{ - "name": "hackerAPI", - "version": "0.0.8", - "description": "Documentation for the API used for mchacks", - "defaultVersion": "0.0.8", - "title": "hackerAPI documentation", - "url": "https://api.mchacks.ca/api", - "sampleUrl": "https://api.mchacks.ca/api", - "apidoc": "0.3.0", - "generator": { - "name": "apidoc", - "time": "2018-12-20T06:25:49.908Z", - "url": "http://apidocjs.com", - "version": "0.17.6" - } +{ + "name": "hackerAPI", + "version": "0.0.8", + "description": "Documentation for the API used for mchacks", + "defaultVersion": "0.0.8", + "title": "hackerAPI documentation", + "url": "https://api.mchacks.ca/api", + "sampleUrl": "https://api.mchacks.ca/api", + "apidoc": "0.3.0", + "generator": { + "name": "apidoc", + "time": "2019-01-04T19:05:11.619Z", + "url": "http://apidocjs.com", + "version": "0.17.7" + } } \ No newline at end of file diff --git a/docs/api/locales/cs.js b/docs/api/locales/cs.js new file mode 100644 index 00000000..093a24b1 --- /dev/null +++ b/docs/api/locales/cs.js @@ -0,0 +1,25 @@ +define({ + cs: { + 'Allowed values:': 'Povolené hodnoty:', + 'Compare all with predecessor': 'Porovnat vše s předchozími verzemi', + 'compare changes to:': 'porovnat změny s:', + 'compared to': 'porovnat s', + 'Default value:': 'Výchozí hodnota:', + 'Description': 'Popis', + 'Field': 'Pole', + 'General': 'Obecné', + 'Generated with': 'Vygenerováno pomocí', + 'Name': 'Název', + 'No response values.': 'Nebyly vráceny žádné hodnoty.', + 'optional': 'volitelné', + 'Parameter': 'Parametr', + 'Permission:': 'Oprávnění:', + 'Response': 'Odpověď', + 'Send': 'Odeslat', + 'Send a Sample Request': 'Odeslat ukázkový požadavek', + 'show up to version:': 'zobrazit po verzi:', + 'Size range:': 'Rozsah velikosti:', + 'Type': 'Typ', + 'url': 'url' + } +}); \ No newline at end of file diff --git a/docs/api/locales/locale.js b/docs/api/locales/locale.js index ba82385a..880a96cf 100644 --- a/docs/api/locales/locale.js +++ b/docs/api/locales/locale.js @@ -1,5 +1,6 @@ define([ './locales/ca.js', + './locales/cs.js', './locales/de.js', './locales/es.js', './locales/fr.js', @@ -13,7 +14,7 @@ define([ './locales/vi.js', './locales/zh.js', './locales/zh_cn.js' -], function() { +], function () { var langId = (navigator.language || navigator.userLanguage).toLowerCase().replace('-', '_'); var language = langId.substr(0, 2); var locales = {}; @@ -22,10 +23,10 @@ define([ for (property in arguments[index]) locales[property] = arguments[index][property]; } - if ( ! locales['en']) + if (!locales['en']) locales['en'] = {}; - if ( ! locales[langId] && ! locales[language]) + if (!locales[langId] && !locales[language]) language = 'en'; var locale = (locales[langId] ? locales[langId] : locales[language]); @@ -42,9 +43,9 @@ define([ } return { - __ : __, - locales : locales, - locale : locale, + __: __, + locales: locales, + locale: locale, setLanguage: setLanguage }; -}); +}); \ No newline at end of file diff --git a/routes/api/hacker.js b/routes/api/hacker.js index 04a4250d..efef35cb 100644 --- a/routes/api/hacker.js +++ b/routes/api/hacker.js @@ -279,6 +279,9 @@ module.exports = { * @apiParam (body) {String} [school] Name of the school the hacker goes to * @apiParam (body) {String} [gender] Gender of the hacker * @apiParam (body) {Boolean} [needsBus] Whether the hacker requires a bus for transportation + * @apiParam (body) {String[]} [ethnicity] the ethnicities of the hacker + * @apiParam (body) {String} [major] the major of the hacker + * @apiParam (body) {Number} [graduationYear] the graduation year of the hacker * @apiParam (body) {Json} [application] The hacker's application * @apiParamExample {Json} application: * {