Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/sponsors #7170

Merged
merged 12 commits into from
Aug 12, 2020
36 changes: 32 additions & 4 deletions app/assets/v2/js/pages/dashboard-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
this.retrieveSponsorPrizes();
},
methods: {
chatWindow: function(channel) {
let vm = this;
const url = `${vm.chatURL}/hackathons/channels/${channel}`;

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) {
let vm = this;
const url = '/api/v0.1/hackathon_project/set_winner/';
Expand Down Expand Up @@ -65,6 +71,26 @@

return vm.comments[project];
},
focusOut: function(project) {
if (this.comments[project.pk] === '') {
vm.$set(this.comments, project.pk, undefined);
}
},
togglePrize: function(prizeIndex) {
for (let i = 0; i < this.prizes.length; i++) {
if (i === prizeIndex) {
vm.$set(this.prizes[i], 'open', !this.prizes[prizeIndex].open);
} else {
vm.$set(this.prizes[i], 'open', false);
}
}
},
sortedProjects: function(prize) {
const copy_submissions = [...prize.submissions];

copy_submissions.sort((a, b) => b.timestamp - a.timestamp);
return copy_submissions;
},
retrieveSponsorPrizes: function() {
const vm = this;
const hackathon = fetchData(`/api/v1/hackathon/${vm.hackathonObj['slug']}/prizes`);
Expand All @@ -73,7 +99,9 @@
for (let i = 0; i < response.prizes.length; i++) {
if (response.prizes[i].submissions.length) {
response.prizes[i].submissions.forEach((submission) => {
vm.$set(vm.comments, submission.pk, submission.extra.notes);
if (submission.extra.notes !== '') {
vm.$set(vm.comments, submission.pk, submission.extra.notes);
}
});
}
}
Expand Down Expand Up @@ -112,21 +140,21 @@
toggleSummary: function(prizeIndex, submissionIndex) {
let vm = this;
const showDescription = !vm.prizes[prizeIndex].submissions[submissionIndex].showDescription;

vm.$set(vm.prizes[prizeIndex].submissions[submissionIndex], 'showDescription', showDescription);
}
},
computed: {
isMobileDevice() {
return this.windowWidth < 576;
return window.innerWidth < 576;
}
},
data: () => ({
activePanel: document.activePanel,
hackathonObj: document.hackathonObj,
hackathonSponsors: document.hackathonSponsors,
hackathonProjects: [],
chatURL: document.chatURL,
chatURL: document.chatURL || 'https://chat.gitcoin.co/',
prizes: [],
comments: [],
csrf: $("input[name='csrfmiddlewaretoken']").val() || ''
Expand Down
3 changes: 2 additions & 1 deletion app/assets/v2/js/pages/fulfill_bounty/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ fulfillBounty = data => {
'metadata': JSON.stringify(metadata),
'fulfiller_address': data.payoutAddress,
'fulfiller_identifier': data.fulfiller_identifier,
'payout_type': web3_type
'payout_type': web3_type,
'projectId': data.projectId
};

$.post(url, params, function(response) {
Expand Down
19 changes: 19 additions & 0 deletions app/dashboard/migrations/0139_bountyfulfillment_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.4 on 2020-08-11 00:29

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0138_auto_20200810_1301'),
]

operations = [
migrations.AddField(
model_name='bountyfulfillment',
name='project',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='submissions', to='dashboard.HackathonProject'),
),
]
22 changes: 20 additions & 2 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from django.db.models.signals import m2m_changed, post_delete, post_save, pre_save
from django.dispatch import receiver
from django.forms.models import model_to_dict
from django.template.defaultfilters import date
from django.template.loader import render_to_string
from django.templatetags.static import static
from django.urls import reverse
Expand Down Expand Up @@ -1381,6 +1382,7 @@ class BountyFulfillment(SuperModel):
# TODO: rename to submission_url
fulfiller_github_url = models.CharField(max_length=255, blank=True, null=True)
funder_last_notified_on = models.DateTimeField(null=True, blank=True)
project = models.ForeignKey('dashboard.HackathonProject', null=True, on_delete=models.SET_NULL, related_name='submissions')

accepted = models.BooleanField(default=False, help_text="has the fulfillment been accepted by the funder")
accepted_on = models.DateTimeField(null=True, blank=True, help_text="date when the fulfillment was accepted by the funder")
Expand Down Expand Up @@ -4909,9 +4911,20 @@ def to_json(self):
'email': profile.email,
'payout_address': profile.preferred_payout_address,
'url': profile.url,
'avatar': profile.active_avatar.avatar_url if profile.active_avatar else ''
'avatar': profile.active_avatar.avatar_url if profile.active_avatar else '',
'id': profile.pk
} for profile in self.profiles.all()
]
profile_ids = [profile['id'] for profile in profiles]

submission = BountyFulfillment.objects.filter(project=self).first()
# Backward compatibility, for bounty fulfillment without a project assigned
if not submission:
submission = BountyFulfillment.objects.filter(profile_id__in=profile_ids, bounty=self.bounty).first()

paid = False
if submission:
paid = submission.payout_status == 'done'

return {
'pk': self.pk,
Expand All @@ -4922,10 +4935,15 @@ def to_json(self):
'work_url': self.work_url,
'summary': self.summary,
'status': self.status,
'submitted': bool(submission),
'submition_date': date(submission.created_on, 'Y-m-d H:i') if submission else '',
'message': self.message,
'chat_channel_id': self.chat_channel_id,
'paid': paid,
'payment_date': date(submission.accepted_on, 'Y-m-d H:i') if paid else '',
'winner': self.winner,
'extra': self.extra
'extra': self.extra,
'timestamp': submission.created_on.timestamp() if submission else 0
}


Expand Down
19 changes: 19 additions & 0 deletions app/dashboard/templates/bounty/fulfill.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ <h4 class="text-center mb-4">{% trans "Submit Work" %}</h4>
/>
</div>

{% if prize_projects %}
<div class="mt-2">
<label class="form__label" for="projectId">{% trans "Select the submitting project" %}</label>
<select name='projectId' id='projectId' class="form__input w-100 js-select2 font-body" required>
{% for project in prize_projects %}
<option value="{{ project.id }}">{{ project.id }} - {{ project.name }}</option>
{% endfor %}
</select>
</div>
{% endif %}

{% if bounty.web3_type == 'fiat' %}
<div class="mt-2">
<label class="form__label" for="fulfiller_identifier">{% trans "Paypal Account" %}</label>
Expand Down Expand Up @@ -185,6 +196,14 @@ <h4 class="text-center mb-4">{% trans "Submit Work" %}</h4>
standardBountyId = {{bounty.standard_bounties_id}};
eventTag = '{{ bounty.event.slug }}';
{% endif %}

$(document).ready(function() {
$('.js-select2').each(function() {
$(this).select2({
minimumResultsForSearch: Infinity
});
});
})
</script>

{% if is_bounties_network %}
Expand Down
61 changes: 40 additions & 21 deletions app/dashboard/templates/dashboard/sponsors.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
border-top: none !important;
}

.no-submitted {
background-color: #F3F3F3;
}

.mobile-separator {
border-bottom: 1px solid #D1D1D1;
}
Expand Down Expand Up @@ -100,6 +104,10 @@
.custom-control-label::before {
top: 0rem !important;
}
.tag {
height: 21px;
margin-top: 0;
}
</style>
{% include 'shared/fbpixel.html' %}
</head>
Expand Down Expand Up @@ -171,38 +179,39 @@
</div>
<div role="tablist">
<b-card no-body class="my-3" v-for="(prize, prizeIndex) in prizes" v-if="prizes">
<b-card-header header-tag="header" class="row mx-0 px-4 py-2 bg-white" role="tab">
<b-card-header header-tag="header" class="justify-content-between row mx-0 px-4 py-2 bg-white" role="tab">

<div class="col-12 col-md-5 text-center text-md-left pl-md-0">
<div class="my-2">
<p class="m-0">
<p class="m-0 d-md-flex">
<a target="_blank" :href="prize.url" class="font-body font-weight-semibold d-inline-block text-black">
[[`${prize.title.slice(0, 100)}${prize.title.length > 100 ? '...' : ''}`]]
</a>
<span v-if="prize.value_eth" class="ml-3 tag token">[[prize.value_eth | decimals]] ETH</span>
<span v-if="prize.values_usdt" class="tag usd">[[prize.values_usdt]] USD</span>
</p>

</div>
</div>

<div class="col-md-3 my-auto">
<p class="mb-3 m-md-0 text-center">
<span v-if="prize.value_eth" class="tag token">[[prize.value_eth | decimals]] ETH</span>
<span v-if="prize.values_usdt" class="tag usd">[[prize.values_usdt]] USD</span>
<p class="mb-3 m-md-0 text-left">

</p>
</div>

<div class="col-md-5 col-lg-4 my-auto font-body font-weight-semibold text-center">
<p v-if="!prize.total_projects" class="font-body font-weight-semibold m-0">No Submissions</p>
<p v-if="!prize.total_projects" class="font-body font-weight-semibold m-0 text-left">No Submissions</p>

<p v-else class="m-0 position-relative">
<p v-else class="m-0 position-relative text-left">
<span>
[[ prize.total_submitted ]] / [[prize.total_projects]] Submitted
</span>
<span v-if="prize.paid" class="ml-5 gc-text-green"><span class="fas fa-check mr-2"></span>PAID</span>
<a v-else :href="`/issue/payout?pk=${prize.pk}`" class="ml-2 ml-xl-5 btn btn-outline-primary font-smaller-5">PAY</a>
<span v-if="prize.paid" class="ml-5 gc-text-green"><span class="fas fa-check mr-2"></span>Paid</span>
<span v-else v-b-toggle="`accordion-${prizeIndex}`" @click="togglePrize(prizeIndex)" class="ml-5 gc-text-blue">Review Submission</span>

<b-button style="right: 0;top: -5px" class="position-absolute" v-if="prize.total_projects" v-b-toggle="`accordion-${prizeIndex}`" variant="link">
<i class="fas fa-angle-up"></i>
<b-button style="right: 0;top: -5px" class="position-absolute" v-if="prize.total_projects" v-b-toggle="`accordion-${prizeIndex}`" @click="togglePrize(prizeIndex)" variant="link">
<i class="fas fa-angle-up" v-if="!prize.open"></i>
<i class="fas fa-angle-down" v-else></i>
Copy link
Member

@thelostone-mc thelostone-mc Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<i class="fas fa-angle-down" v-if="prize.open"></i>
<i class="fas fa-angle-up" v-else></i>

</b-button>
</p>
</div>
Expand All @@ -213,22 +222,25 @@
<b-card-body>
<b-table-simple hover small caption-top responsive>
<b-thead v-if="!isMobileDevice">
<b-th>Submission</b-th>
<b-th>Projects</b-th>
<b-th>Project Description</b-th>
<b-th>Hacker</b-th>
<b-th>Contact</b-th>
<b-th>Winner</b-th>
<b-th>Payment</b-th>
<b-th>Notes</b-th>
</b-thead>
<b-tbody>
<b-tr :class="isMobileDevice ? 'd-flex flex-column mobile-separator py-3 px-3': 'py-4'" v-for="(project, projectIndex) in prize.submissions">
<b-td :class="isMobileDevice ? 'no-border mt-2': 'py-4'">
<img :src="project.logo" alt="" width="30">
<a :href="project.work_url" target="_blank"><span class="fab fa-github text-black"></span>
<span class="font-body gc-text-blue font-weight-semibold">[[project.name]]</span>
<b-tr :class="`${!project.submitted ? 'no-submitted' : ''} ${isMobileDevice ? 'd-flex flex-column mobile-separator py-3 px-3': 'py-4'}`" v-for="(project, projectIndex) in sortedProjects(prize)">
<b-td :class="`position-relative ${isMobileDevice ? 'no-border mt-2': 'py-4'}`">
<img :src="project.logo" class="align-baseline" alt="" width="30">
<a :href="project.work_url" class="ml-2" target="_blank">
<p class="d-inline-block mb-0 font-body gc-text-blue font-weight-semibold">[[`${project.name.slice(0, 100)}${project.name.length > 100 ? '...' : ''}`]]<br>
<span class="fab fa-github text-black"></span></p>
</a>
<br>
<i style="bottom: 5px" :class="`font-weight-semibold ${!isMobileDevice ? 'position-absolute' : '' } mt-sm-2 font-smaller-2 mt-2`" v-if="!project.submitted">Not Submitted</i>
</b-td>

<b-td :class="isMobileDevice ? 'no-border mt-2': 'py-4 summary pr-4'">

<p class="mt-1">[[getSummary(project)]]
Expand All @@ -241,7 +253,7 @@
<div class="d-flex mb-2 mt-1" v-for="profile in project.profiles">
<img height="28" width="28" class="mr-2 rounded-circle" :src="`https://gitcoin.co/dynamic/avatar/${profile.handle}`" alt="">
<div class="d-flex flex-column">
<a class="font-smaller-4 text-black" :href="profile.url">[[profile.handle]]</a>
<a class="font-smaller-4 text-black" target="_blank" :href="profile.url">[[profile.handle]]</a>
<span class="font-smaller-5 gc-text-blue">[[start_and_end(profile.payout_address)]]</span>
</div>
</div>
Expand All @@ -255,12 +267,19 @@
Winner
</b-form-checkbox>
</b-td>
<b-td :class="isMobileDevice ? 'no-border mt-2': 'py-4'">
thelostone-mc marked this conversation as resolved.
Show resolved Hide resolved
<template v-if="project.winner">
<a class="btn btn-gc-blue font-body" target="_blank" :href="`/issue/payout?pk=${prize.pk}`" v-if="!project.paid">Pay</a>
<p class="font-body" v-else>Paid [[ project.payment_date ]]</p>
</template>
</b-td>

<b-td :class="isMobileDevice ? 'no-border mt-2': 'py-4'">
<button class="btn btn-link gc-text-blue pt-0 font-smaller-4 mt-1" @click="addNote(project)" v-if="comments[project.pk] == undefined">
<i class="fas fa-plus mr-1"></i>
Add Note
</button>
<textarea v-if="comments[project.pk] != undefined" v-model="comments[project.pk]" @change="setNote($event, project)" class="form-control note">[[getComment(project.pk)]]</textarea>
<textarea v-if="comments[project.pk] != undefined" v-model="comments[project.pk]" @change="setNote($event, project)" @blur="focusOut(project)" class="form-control note" placeholder="This note can only be viewed by you">[[getComment(project.pk)]]</textarea>
</b-td>
</b-tr>
</b-tbody>
Expand Down
Loading