Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/static/riot/competitions/detail/_tabs.tag
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
38 changes: 28 additions & 10 deletions src/static/riot/competitions/detail/submission_upload.tag
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<div class="submission-form">
<h1>Submission upload</h1>
<div if="{_.get(selected_phase, 'phase_ended')}" class="ui red message">This phase has ended and no longer accepts submissions!</div>
<div if="{!_.get(selected_phase, 'phase_started')}" class="ui yellow message">This phase hasn't started yet!</div>
<form class="ui form coda-animated {error: errors}" ref="form" enctype="multipart/form-data">
<div class="submission-form" ref="fact_sheet_form" if="{ opts.fact_sheet !== null}">
<h2>Metadata or Fact Sheet</h2>
Expand Down Expand Up @@ -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 () {
Expand Down
Binary file modified src/tests/functional/test_files/competition.zip
Binary file not shown.
Binary file modified src/tests/functional/test_files/competition_18.zip
Binary file not shown.