Skip to content

Commit

Permalink
Allow multiple submissions (#7302)
Browse files Browse the repository at this point in the history
Co-authored-by: Aditya Anand M C <[email protected]>
  • Loading branch information
zoek1 and thelostone-mc authored Oct 14, 2020
1 parent 2ccfbc4 commit 0c495b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
17 changes: 1 addition & 16 deletions app/assets/v2/js/pages/dashboard-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,14 @@

window.open(url, 'Loading', 'top=0,left=0,width=400,height=600,status=no,toolbar=no,location=no,menubar=no,titlebar=no');
},
markWinner: function($event, project, prizeIndex) {
markWinner: function($event, project) {
let vm = this;
const url = '/api/v0.1/hackathon_project/set_winner/';
const markWinner = fetchData(url, 'POST', {
project_id: project.pk,
winner: $event ? 1 : 0
}, {'X-CSRFToken': vm.csrf});

vm.prizes[prizeIndex].submissions.forEach((submission, submissionIndex) => {
if (submission.pk !== project.pk && submission.winner) {
console.log(submission.pk);
console.log(project.pk);
const unmarkPreviousWinner = fetchData(url, 'POST', {
project_id: submission.pk,
winner: 0
}, {'X-CSRFToken': vm.csrf});

$.when(unmarkPreviousWinner).then(() => {
vm.$set(vm.prizes[prizeIndex].submissions[submissionIndex], 'winner', false);
});
}
});

$.when(markWinner).then(response => {
if (response.message) {
alert(response.message);
Expand Down
20 changes: 1 addition & 19 deletions app/assets/v2/js/vue-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,32 +617,14 @@ Vue.component('project-card', {
}
},
methods: {
markWinner: function($event, project) {
let vm = this;

const url = '/api/v0.1/hackathon_project/set_winner/';
const markWinner = fetchData(url, 'POST', {
project_id: project.pk,
winner: $event ? 1 : 0
}, {'X-CSRFToken': vm.csrf});

$.when(markWinner).then(response => {
if (response.message) {
alert(response.message);
}
}).catch(err => {
console.log(err);
});
},
projectModal() {
let project = this.$props.project;

projectModal(project.bounty.pk, project.pk);
}
},
template: `<div class="card card-user shadow-sm border-0">
<div class="card card-project">
<b-form-checkbox v-if="is_staff" switch v-model="project.winner" style="padding:0;float:left;" @change="markWinner($event, project)">mark winner</b-form-checkbox>
<div class="card card-project">
<button v-on:click="projectModal" class="position-absolute btn btn-gc-green btn-sm m-2" style="left: 0.5rem; top: 3rem" id="edit-btn" v-bind:class="{ 'd-none': !edit }">edit</button>
<img v-if="project.grant_obj" class="position-absolute" style="left: 1rem" src="${static_url}v2/images/grants/grants-tag.svg" alt="grant_tag"/>
<img v-if="project.badge" class="position-absolute card-badge" width="50" :src="profile.badge" alt="badge" />
Expand Down

0 comments on commit 0c495b5

Please sign in to comment.