Skip to content

Commit

Permalink
Merge pull request #3709 from gitcoinco/pr/3424
Browse files Browse the repository at this point in the history
feedback implementation (continuation of #3424)
  • Loading branch information
thelostone-mc authored Mar 7, 2019
2 parents a2ba894 + fbc3b0b commit ef43896
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 17 deletions.
1 change: 1 addition & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
# dashboard views
re_path(r'^onboard/(?P<flow>\w+)/$', dashboard.views.onboard, name='onboard'),
re_path(r'^onboard/contributor/avatar/?$', dashboard.views.onboard_avatar, name='onboard_avatar'),
url(r'^postcomment/', dashboard.views.post_comment, name='post_comment'),
url(r'^dashboard/?', dashboard.views.dashboard, name='dashboard'),
url(r'^explorer/?', dashboard.views.dashboard, name='explorer'),
path('revenue/attestations/new', revenue.views.new_attestation, name='revenue_new_attestation'),
Expand Down
43 changes: 43 additions & 0 deletions app/assets/v2/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,49 @@ input.is-invalid {
width: auto;
}

.rating {
width:160px;
}
.rating span { float:right; position:relative; }
.rating span input {
position:absolute;
top:0px;
left:0px;
opacity:0;
}
.rating span label {
display:inline-block;
width:30px;
height:30px;
text-align:center;
color:#FFF;
font-size:25px;
margin-right:2px;
line-height:30px;
border-radius:50%;
-webkit-border-radius:50%;
}
.rating span label i {
color:#ccc;
}

.rating span:hover ~ span label i,
.rating span:hover label i {
opacity: 0.5;
}
.rating span.checked label i,
.rating span.checked ~ span label i
{
opacity: 1;
}

.rating span:hover ~ span label i,
.rating span:hover label i,
.rating span.checked label i,
.rating span.checked ~ span label i {
color: rgb(18,199,113);
}

.bounty_box {
border: 5px solid white;
width: 100%;
Expand Down
41 changes: 36 additions & 5 deletions app/assets/v2/js/pages/fulfill_bounty.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
/* eslint-disable no-console */
window.onload = function() {

// Check Radio-box
$('.rating input:radio').attr('checked', false);

$('.rating input').click(function() {
$('.rating span').removeClass('checked');
$(this).parent().addClass('checked');
});

$('input:radio').change(
function() {
var userRating = this.value;
});

// a little time for web3 injection
setTimeout(function() {
waitforWeb3(actions_page_warn_if_not_on_same_network);
Expand Down Expand Up @@ -102,11 +116,28 @@ window.onload = function() {
txid: result
});

dataLayer.push({ event: 'claimissue' });
_alert({ message: gettext('Fulfillment submitted to web3.') }, 'info');
setTimeout(() => {
document.location.href = '/funding/details?url=' + issueURL;
}, 1000);
var submitCommentUrl = '/postcomment/';
var finishedComment = function() {
dataLayer.push({ event: 'claimissue' });
_alert({ message: gettext('Fulfillment submitted to web3.') }, 'info');
setTimeout(() => {
document.location.href = '/funding/details?url=' + issueURL;
}, 1000);
};
var ratVal = $('input:radio[name=rating]:checked').val();
var revVal = $('#review').val();

$.post(submitCommentUrl, {
'github_url': issueURL,
'network': $('input[name=network]').val(),
'standard_bounties_id': $('input[name=standard_bounties_id]').val(),
'review': {
'rating': ratVal ? ratVal : -1,
'comment': revVal ? revVal : 'No comment given.',
'reviewType': 'worker',
'receiver': ''
}
}, finishedComment, 'json');
};

if (error) {
Expand Down
41 changes: 37 additions & 4 deletions app/assets/v2/js/pages/process_bounty.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
/* eslint-disable no-console */
window.onload = function() {

// Check Radio-box
$('.rating input:radio').attr('checked', false);

$('.rating input').click(function() {
$('.rating span').removeClass('checked');
$(this).parent().addClass('checked');
});

$('input:radio').change(
function() {
var userRating = this.value;
});

// a little time for web3 injection
setTimeout(function() {
waitforWeb3(actions_page_warn_if_not_on_same_network);
Expand Down Expand Up @@ -205,10 +219,29 @@ window.onload = function() {
'txid': result
});

_alert({ message: gettext('Submitted transaction to web3.') }, 'info');
setTimeout(() => {
document.location.href = '/funding/details?url=' + issueURL;
}, 1000);
_alert({ message: gettext('Submitted transaction to web3, saving comment(s)...') }, 'info');

var submitCommentUrl = '/postcomment/';
var finishedComment = function() {
_alert({ message: gettext('Submitted transaction to web3.') }, 'info');
setTimeout(() => {
document.location.href = '/funding/details?url=' + issueURL;
}, 1000);
};
var ratVal = $('input:radio[name=rating]:checked').val();
var revVal = $('#review').val();

$.post(submitCommentUrl, {
'github_url': issueURL,
'network': $('input[name=network]').val(),
'standard_bounties_id': $('input[name=standard_bounties_id]').val(),
'review': {
'rating': ratVal ? ratVal : -1,
'comment': revVal ? revVal : 'No comment given.',
'reviewType': 'approver',
'receiver': getSelectedFulfillment().getAttribute('username')
}
}, finishedComment, 'json');

};

Expand Down
6 changes: 5 additions & 1 deletion app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from .models import (
Activity, BlockedUser, Bounty, BountyFulfillment, BountySyncRequest, CoinRedemption, CoinRedemptionRequest,
Interest, LabsResearch, Profile, SearchHistory, Tip, TokenApproval, Tool, ToolVote, UserAction,
FeedbackEntry, Interest, LabsResearch, Profile, SearchHistory, Tip, TokenApproval, Tool, ToolVote, UserAction,
UserVerificationModel,
)

Expand Down Expand Up @@ -75,6 +75,9 @@ class UserActionAdmin(admin.ModelAdmin):
search_fields = ['action', 'ip_address', 'metadata', 'profile__handle']
ordering = ['-id']

class FeedbackAdmin(admin.ModelAdmin):
search_fields = ['sender_profile','receiver_profile','bounty','feedbackType']
ordering = ['-id']

class ProfileAdmin(admin.ModelAdmin):
raw_id_fields = ['user', 'preferred_kudos_wallet']
Expand Down Expand Up @@ -174,5 +177,6 @@ def network_link(self, instance):
admin.site.register(CoinRedemptionRequest, GeneralAdmin)
admin.site.register(Tool, ToolAdmin)
admin.site.register(ToolVote, ToolVoteAdmin)
admin.site.register(FeedbackEntry, FeedbackAdmin)
admin.site.register(LabsResearch)
admin.site.register(UserVerificationModel)
10 changes: 7 additions & 3 deletions app/dashboard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ def handle_bounty_fulfillments(fulfillments, new_bounty, old_bounty):
except Exception as e:
logger.error(f'{e} during new fulfillment creation for {new_bounty}')
continue
return new_bounty.fulfillments.all()

if new_bounty:
return new_bounty.fulfillments.all()


def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id):
Expand Down Expand Up @@ -533,10 +535,10 @@ def process_bounty_details(bounty_details):
meta = bounty_data.get('meta', {})

# what schema are we working with?
schema_name = meta.get('schemaName')
schema_name = meta.get('schemaName', 'Unknown')
schema_version = meta.get('schemaVersion', 'Unknown')
if not schema_name or schema_name != 'gitcoinBounty':
logger.info('Unknown Schema: Unknown - Version: %s', schema_version)
logger.info('Unknown Schema: %s - Version: %s', schema_name, schema_version)
return (False, None, None)

# Create new bounty (but only if things have changed)
Expand Down Expand Up @@ -643,6 +645,7 @@ def record_bounty_activity(event_name, old_bounty, new_bounty, _fulfillment=None
user_profile = Profile.objects.filter(handle__iexact=fulfillment.fulfiller_github_username).first()
if not user_profile:
user_profile = sync_profile(fulfillment.fulfiller_github_username)

except Exception as e:
logger.error(f'{e} during record_bounty_activity for {new_bounty}')

Expand Down Expand Up @@ -739,6 +742,7 @@ def process_bounty_changes(old_bounty, new_bounty):
record_user_action(event_name, old_bounty, new_bounty)
record_bounty_activity(event_name, old_bounty, new_bounty)


# Build profile pairs list
if new_bounty.fulfillments.exists():
profile_pairs = build_profile_pairs(new_bounty)
Expand Down
32 changes: 32 additions & 0 deletions app/dashboard/migrations/0015_auto_20190228_1027.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 2.1.7 on 2019-02-28 10:27

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


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0014_merge_20190221_2246'),
]

operations = [
migrations.CreateModel(
name='FeedbackEntry',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)),
('modified_on', models.DateTimeField(default=economy.models.get_time)),
('rating', models.SmallIntegerField(blank=True, default=0)),
('comment', models.TextField(blank=True, default='')),
('feedbackType', models.TextField(blank=True, default='', max_length=20)),
('bounty', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='feedbacks', to='dashboard.Bounty')),
('receiver_profile', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='feedbacks_got', to='dashboard.Profile')),
('sender_profile', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='feedbacks_sent', to='dashboard.Profile')),
],
options={
'abstract': False,
},
),
]
14 changes: 14 additions & 0 deletions app/dashboard/migrations/0018_merge_20190307_1314.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.1.7 on 2019-03-07 13:14

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0017_merge_20190305_2048'),
('dashboard', '0015_auto_20190228_1027'),
]

operations = [
]
32 changes: 31 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,6 @@ def submitted(self):
"""Exclude results that have not been submitted."""
return self.exclude(fulfiller_address='0x0000000000000000000000000000000000000000')


class BountyFulfillment(SuperModel):
"""The structure of a fulfillment on a Bounty."""

Expand Down Expand Up @@ -2889,3 +2888,34 @@ class BlockedUser(SuperModel):
def __str__(self):
"""Return the string representation of a Bounty."""
return f'<BlockedUser: {self.handle}>'


class FeedbackEntry(SuperModel):
bounty = models.ForeignKey(
'dashboard.Bounty',
related_name='feedbacks',
on_delete=models.CASCADE,
blank=True,
null=True
)
sender_profile = models.ForeignKey(
'dashboard.Profile',
related_name='feedbacks_sent',
on_delete=models.CASCADE,
blank=True,
null=True
)
receiver_profile = models.ForeignKey(
'dashboard.Profile',
related_name='feedbacks_got',
on_delete=models.CASCADE,
blank=True,
null=True
)
rating = models.SmallIntegerField(blank=True, default=0)
comment = models.TextField(default='', blank=True)
feedbackType = models.TextField(default='', blank=True, max_length=20)

def __str__(self):
"""Return the string representation of a Bounty."""
return f'<Feedback Bounty #{self.bounty} - from: {self.sender_profile} to: {self.receiver_profile}>'
1 change: 1 addition & 0 deletions app/dashboard/templates/bounty/fulfill.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ <h1 class="text-center title">{% trans "Submit Work" %}</h1>
</div>
{% include 'shared/github_link.html' %}
{% include 'shared/hours_worked.html' %}
{% include 'shared/rating.html' with counterparty='funder' %}
<div id="gas-section" class="mt-4">
{% include 'shared/bounty_actions_hidden_vars.html' %}
{% include 'shared/wallet_estimate.html' %}
Expand Down
3 changes: 2 additions & 1 deletion app/dashboard/templates/process_bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ <h3>{% trans "Basic Payout" %}</h3>
{% endfor %}
</select>
</div>
<div class="w-100 my-2">
{% include 'shared/rating.html' with counterparty='contributor' %}
<div class="w-100 mt-2">
<label for=tipPercent>{% trans "(Optional) Add a tip of:" %}</label>
<input name='tipPercent' id="tipPercent" class="gc-round-text-input gc-border-blue" style="width: 50px;" type="number" placeholder="" value="0" min="0" /> % worth <span id="tipEstimate">0</span> {{bounty.token_name}}
</div>
Expand Down
30 changes: 30 additions & 0 deletions app/dashboard/templates/shared/rating.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% comment %}
Copyright (C) 2018 Gitcoin Core

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load i18n %}
<div class="w-100 mt-2" style="height: 70px;">
<label class="form__label" for="notificationEmail">{% trans "Rate your experience with the " %}{{ counterparty }}</label>
<div class="rating">
{% for i in "54321" %}
<span><input type="radio" name="rating" id="str{{ i }}" value="{{ i }}"><label for="str{{ i }}"><i class="fas fa-star"></i></label></span>
{% endfor %}
</div>
</div>
<div class="w-100 mt-2">
<label class="form__label" for="review">{% trans "Review" %}</label>
<textarea name='review' id='review' class="form__input" placeholder="{% trans "Any feedback for the " %} {{ counterparty }}? {% trans "Write it here" %}" ></textarea>
</div>

1 change: 1 addition & 0 deletions app/dashboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ def get_bounty(bounty_enum, network):
'token': token,
'fulfillments': fulfillments,
'network': network,
'review': bounty_data.get('review',{}),
}
return bounty

Expand Down
Loading

0 comments on commit ef43896

Please sign in to comment.