diff --git a/src/static/riot/competitions/detail/_tabs.tag b/src/static/riot/competitions/detail/_tabs.tag index 15a8246b3..719308664 100644 --- a/src/static/riot/competitions/detail/_tabs.tag +++ b/src/static/riot/competitions/detail/_tabs.tag @@ -280,6 +280,40 @@ }) }) + // loop over competition phases to mark if phase has started or ended + self.competition.phases.forEach(function (phase, index) { + + phase_ended = false + phase_started = false + + // check if phase has started + if((Date.parse(phase["start"]) - Date.parse(new Date())) > 0){ + // start date is in the future, phase started = NO + phase_started = false + }else{ + // start date is not in the future, phase started = YES + phase_started = true + } + + if(phase_started){ + // check if end data exists for this phase + if(phase["end"]){ + if((Date.parse(phase["end"]) - Date.parse(new Date())) < 0){ + // Phase cannote accept submissions if end date is in the past + phase_ended = true + }else{ + // Phase can accept submissions if end date is in the future + phase_ended = false + } + }else{ + // Phase can accept submissions if end date is not given + phase_ended = false + } + } + self.competition.phases[index]["phase_ended"] = phase_ended + self.competition.phases[index]["phase_started"] = phase_started + }) + self.competition.is_admin = CODALAB.state.user.has_competition_admin_privileges(competition) self.selected_phase_index = _.get(_.find(self.competition.phases, {'status': 'Current'}), 'id') if (self.selected_phase_index == null) { diff --git a/src/static/riot/competitions/detail/submission_upload.tag b/src/static/riot/competitions/detail/submission_upload.tag index 4172bd78a..f1405cfb9 100644 --- a/src/static/riot/competitions/detail/submission_upload.tag +++ b/src/static/riot/competitions/detail/submission_upload.tag @@ -4,6 +4,8 @@

Submission upload

+
This phase has ended and no longer accepts submissions!
+
This phase hasn't started yet!

Metadata or Fact Sheet

@@ -349,17 +351,33 @@ } self.check_can_upload = function () { - CODALAB.api.can_make_submissions(self.selected_phase.id) - .done(function (data) { - if (data.can) { - self.prepare_upload(self.upload)() - } else { - toastr.error(data.reason) + + // Check if selected phase accepts submissions (within the deadline of the phase) + if(self.selected_phase.phase_started && !self.selected_phase.phase_ended){ + + CODALAB.api.can_make_submissions(self.selected_phase.id) + .done(function (data) { + if (data.can) { + self.prepare_upload(self.upload)() + } else { + toastr.error(data.reason) + } + }) + .fail(function (data) { + toastr.error('Could not verify your ability to make a submission') + }) + }else{ + // Error when phase is not accepting submissions + if(!self.selected_phase.phase_started){ + toastr.error('This phase has not started yet. Please check the phase start date!') + + }else { + if(self.selected_phase.phase_ended){ + toastr.error('This phase has ended and no longer accepts submissions!') } - }) - .fail(function (data) { - toastr.error('Could not verify your ability to make a submission') - }) + } + self.clear_form() + } } self.get_fact_sheet_answers = function () { diff --git a/src/tests/functional/test_files/competition.zip b/src/tests/functional/test_files/competition.zip index ff2121d6a..005fba612 100644 Binary files a/src/tests/functional/test_files/competition.zip and b/src/tests/functional/test_files/competition.zip differ diff --git a/src/tests/functional/test_files/competition_18.zip b/src/tests/functional/test_files/competition_18.zip index e0ed2aeef..f5afa821d 100644 Binary files a/src/tests/functional/test_files/competition_18.zip and b/src/tests/functional/test_files/competition_18.zip differ