diff --git a/actions/srmRoundManagement.js b/actions/srmRoundManagement.js index f2c512659..c046bbcb0 100644 --- a/actions/srmRoundManagement.js +++ b/actions/srmRoundManagement.js @@ -376,11 +376,13 @@ function checkContestRound(helper, obj) { helper.checkNumber(obj.roomAssignment.p, 'roomAssignment.p') || helper.checkString(obj.name, 'name') || helper.checkString(obj.status, 'status') || - helper.checkString(obj.short_name, 'short_name'); + helper.checkString(obj.short_name, 'short_name') || + helper.checkBoolean(obj.auto_end, 'auto_end'); if (!error) { obj.roomAssignment.isByDivision = obj.roomAssignment.isByDivision ? 1 : 0; obj.roomAssignment.isByRegion = obj.roomAssignment.isByRegion ? 1 : 0; obj.roomAssignment.isFinal = obj.roomAssignment.isFinal ? 1 : 0; + obj.auto_end = obj.auto_end ? 1 : 0; } return error; } @@ -399,7 +401,7 @@ exports.createSRMContestRound = { inputs: { required: ['contest_id', 'type', 'invitationalType', 'region', 'registrationLimit', 'roomAssignment', 'name', 'status', 'short_name'], - optional: [] + optional: ['auto_end'] }, blockedConnectionTypes: [], outputExample: {}, @@ -412,6 +414,9 @@ exports.createSRMContestRound = { params = connection.params || {}, helper = api.helper; + if (_.isUndefined(params.auto_end)) { + params.auto_end = false; + } if (!connection.dbConnectionMap) { helper.handleNoConnection(api, connection, next); return; @@ -445,7 +450,8 @@ exports.createSRMContestRound = { region_id: params.region.region_id, name: params.name, status: params.status, - short_name: params.short_name + short_name: params.short_name, + auto_end: params.auto_end }, dbConnectionMap, cbx); } diff --git a/actions/terms.js b/actions/terms.js index 392dfda8e..0baeb0efb 100755 --- a/actions/terms.js +++ b/actions/terms.js @@ -58,6 +58,8 @@ var getTermsOfUse = function (api, connection, dbConnectionMap, next) { return; } + sqlParams.userId = connection.caller.userId; + async.waterfall([ function (cb) { // validate termsOfUseId parameter and set sql parameter diff --git a/apiary.apib b/apiary.apib index 235aef0c5..a814ebf4b 100644 --- a/apiary.apib +++ b/apiary.apib @@ -7338,6 +7338,7 @@ Request * type (required, object) round's type, it's id should be set. * region (required, object) round's region, it's id should be set. * roomAssignment (required, object) round's roomAssginment, with field codersPerRoom(integer), type(integer), isByDivision, isByRegion, isFinal(boolean), p(Number). + * auto_end (optional, boolean) auto end flag + Response 200 (application/json) diff --git a/queries/get_terms_of_use b/queries/get_terms_of_use index 07cb163c1..74a2a817b 100644 --- a/queries/get_terms_of_use +++ b/queries/get_terms_of_use @@ -4,8 +4,10 @@ SELECT tou.terms_of_use_id as terms_of_use_id, touat.name as agreeability_type, tou.terms_text as text, touat.terms_of_use_agreeability_type_id as agreeability_type_id, - toudtx.docusign_template_id as docusign_template_id + toudtx.docusign_template_id as docusign_template_id, + (utuox.user_id IS NOT NULL) as agreed FROM terms_of_use tou INNER JOIN terms_of_use_agreeability_type_lu touat ON touat.terms_of_use_agreeability_type_id = tou.terms_of_use_agreeability_type_id LEFT JOIN terms_of_use_docusign_template_xref toudtx ON toudtx.terms_of_use_id = tou.terms_of_use_id +LEFT JOIN user_terms_of_use_xref utuox ON utuox.terms_of_use_id = tou.terms_of_use_id AND utuox.user_id = @userId@ WHERE tou.terms_of_use_id = @termsOfUseId@ diff --git a/queries/insert_srm_contest_round b/queries/insert_srm_contest_round index dc5c3ef49..b07f802a6 100644 --- a/queries/insert_srm_contest_round +++ b/queries/insert_srm_contest_round @@ -1,2 +1,2 @@ -INSERT INTO round (round_id, contest_id, round_type_id, registration_limit, invitational, region_id, name, status, short_name) - VALUES (@round_id@, @contest_id@, @round_type_id@, @registration_limit@, @invitational@, @region_id@, '@name@', '@status@', '@short_name@') +INSERT INTO round (round_id, contest_id, round_type_id, registration_limit, invitational, region_id, name, status, short_name, auto_end) + VALUES (@round_id@, @contest_id@, @round_type_id@, @registration_limit@, @invitational@, @region_id@, '@name@', '@status@', '@short_name@', @auto_end@) diff --git a/test/test.srmRoundManagement.js b/test/test.srmRoundManagement.js index 46a464877..81beeebbc 100644 --- a/test/test.srmRoundManagement.js +++ b/test/test.srmRoundManagement.js @@ -129,7 +129,6 @@ describe('SRM Round Management APIs', function () { clearDb(done); }); - describe("List Round for Contest", function () { describe("Invalid request", function () { /** @@ -660,6 +659,36 @@ describe('SRM Round Management APIs', function () { }); + /** + * Check 400 response if auto_end is a string(not true or false) + */ + it("should return 400 when auto_end is not boolean(1,0,true,false)", function (done) { + var rrequest = requestClone(goodRequest); + rrequest.auto_end = "a"; + assertFail({ + oldRoundId: 1, + json: rrequest, + auth: testHelper.getAdminJwt(), + status: 400, + message: 'auto_end should be 0, 1, true or false.' + }, done); + }); + + /** + * Check 400 response if invitationalType is number(not 0 or 1) + */ + it("should return 400 when auto_end is not boolean(1,0,true,false)", function (done) { + var rrequest = requestClone(goodRequest); + rrequest.auto_end = 10; + assertFail({ + oldRoundId: 1, + json: rrequest, + auth: testHelper.getAdminJwt(), + status: 400, + message: 'auto_end should be 0, 1, true or false.' + }, done); + }); + /** * Check 400 response if contest_id too big */ @@ -1304,7 +1333,6 @@ describe('SRM Round Management APIs', function () { }); - describe("Modify SRM Contest Round", function () { /** diff --git a/test/test_files/srmRoundManagement/good_modify_request.json b/test/test_files/srmRoundManagement/good_modify_request.json index 6014a070c..838b12355 100644 --- a/test/test_files/srmRoundManagement/good_modify_request.json +++ b/test/test_files/srmRoundManagement/good_modify_request.json @@ -15,5 +15,6 @@ }, "name": "create round", "status": "A", - "short_name": "create round short name" + "short_name": "create round short name", + "auto_end": 1 } \ No newline at end of file diff --git a/test/test_files/srmRoundManagement/good_request.json b/test/test_files/srmRoundManagement/good_request.json index b30a99962..e18582d48 100644 --- a/test/test_files/srmRoundManagement/good_request.json +++ b/test/test_files/srmRoundManagement/good_request.json @@ -14,5 +14,6 @@ }, "name": "create round", "status": "A", - "short_name": "create round short name" + "short_name": "create round short name", + "auto_end": 1 } \ No newline at end of file