-
-
Notifications
You must be signed in to change notification settings - Fork 774
[WIP][WOC] feedback implementation (continuation of #1464) #3424
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
Conversation
@@ -45,7 +59,7 @@ window.onload = function() { | |||
var notificationEmail = data.notificationEmail; | |||
var githubPRLink = data.githubPRLink; | |||
var hoursWorked = data.hoursWorked; | |||
|
|||
debugger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 8 spaces but found 2 tabs. (indent)
Unexpected 'debugger' statement. (no-debugger)
} | ||
}, | ||
review: { | ||
rating: data.rating?data.rating:-1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infix operators must be spaced. (space-infix-ops)
}, | ||
review: { | ||
rating: data.rating?data.rating:-1, | ||
comment: data.review?data.review:"No comment given.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infix operators must be spaced. (space-infix-ops)
Strings must use singlequote. (quotes)
review: { | ||
rating: data.rating?data.rating:-1, | ||
comment: data.review?data.review:"No comment given.", | ||
reviewType: "worker" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strings must use singlequote. (quotes)
user_profile = sync_profile(fulfillment.fulfiller_github_username) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W293 blank line contains whitespace
app/dashboard/models.py
Outdated
@@ -999,6 +999,21 @@ def submitted(self): | |||
"""Exclude results that have not been submitted.""" | |||
return self.exclude(fulfiller_address='0x0000000000000000000000000000000000000000') | |||
|
|||
class BountyComment(SuperModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
app/dashboard/models.py
Outdated
@@ -999,6 +999,21 @@ def submitted(self): | |||
"""Exclude results that have not been submitted.""" | |||
return self.exclude(fulfiller_address='0x0000000000000000000000000000000000000000') | |||
|
|||
class BountyComment(SuperModel): | |||
fulfillment = models.ForeignKey(BountyFulfillment, related_name='comments', on_delete=models.CASCADE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F821 undefined name 'BountyFulfillment'
app/dashboard/models.py
Outdated
rating = models.IntegerField(null=True, blank=True) | ||
commentsender = models.ForeignKey('dashboard.Profile', related_name='comments_given', on_delete=models.CASCADE) | ||
commentreceiver = models.ForeignKey('dashboard.Profile', related_name='comments_received', on_delete=models.CASCADE) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W293 blank line contains whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let a few minor comments. Could you fix up the sticker comments and also throw in a working demo ?
.rating { | ||
width:160px; | ||
} | ||
.rating span { float:right; position:relative; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty line between css rules :P
$('.rating input').click(function() { | ||
$('.rating span').removeClass('checked'); | ||
$(this).parent().addClass('checked'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arrow functions :P
$('input:radio').change( | ||
function() { | ||
var userRating = this.value; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable used anywhere?
wait, wait, this is FAR from being finished. This is a WIP and WOC ;-) |
excited for this :) |
Same, but ETHDenver has prio 1 ;-) |
object to helper.py and utils.py.
@@ -68,6 +69,9 @@ class UserActionAdmin(admin.ModelAdmin): | |||
search_fields = ['action', 'ip_address', 'metadata', 'profile__handle'] | |||
ordering = ['-id'] | |||
|
|||
class FeedbackAdmin(admin.ModelAdmin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
@@ -68,6 +69,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'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
return (did_change, latest_old_bounty, new_bounty) | ||
return (did_change, latest_old_bounty, latest_old_bounty) | ||
except SemaphoreExists: | ||
return (did_change, latest_old_bounty, latest_old_bounty) | ||
|
||
def create_new_feedback(new_bounty, feedback_dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
return (did_change, latest_old_bounty, new_bounty) | ||
return (did_change, latest_old_bounty, latest_old_bounty) | ||
except SemaphoreExists: | ||
return (did_change, latest_old_bounty, latest_old_bounty) | ||
|
||
def create_new_feedback(new_bounty, feedback_dict): | ||
feedbackType = feedback_dict.get('feedbackType','???') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
@@ -2778,3 +2777,33 @@ class BlockedUser(SuperModel): | |||
def __str__(self): | |||
"""Return the string representation of a Bounty.""" | |||
return f'<BlockedUser: {self.handle}>' | |||
|
|||
class FeedbackEntry(SuperModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
@@ -361,6 +361,7 @@ def get_bounty(bounty_enum, network): | |||
'token': token, | |||
'fulfillments': fulfillments, | |||
'network': network, | |||
'review': bounty_data.get('review',{}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
@kuhnchris can you please fix the linting issue so that travis passes? |
as repeatedly mentioned: this is not finished. |
return (did_change, latest_old_bounty, new_bounty) | ||
return (did_change, latest_old_bounty, latest_old_bounty) | ||
except SemaphoreExists: | ||
return (did_change, latest_old_bounty, latest_old_bounty) | ||
|
||
def create_new_feedback(new_bounty, feedback_dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ever considered putting this logic into model ? models looks anemic and you create 'create' method in helpers while it can belong to Feedback itself
@classmethod
worker_feedback(cls,bounty,...)
return cls()
@classmethod
other_worker_feedback(cls,bounty,...)
return cls()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, considered that already. The main thing was to get it working, since we are having a IPFS bridge here and it wasn't working very well. especially because we do not simply provide the IPFS later on to the create functions, but actually parse them and return a DIFFERENT json structure than the one we pass into IPFS. Hence those methods are still from the "trying to get this to work" era.
Codecov Report
@@ Coverage Diff @@
## master #3424 +/- ##
==========================================
- Coverage 29.73% 29.71% -0.03%
==========================================
Files 185 185
Lines 14574 14610 +36
Branches 1929 1931 +2
==========================================
+ Hits 4334 4341 +7
- Misses 10101 10130 +29
Partials 139 139
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #3424 +/- ##
=========================================
- Coverage 29.76% 29.7% -0.07%
=========================================
Files 193 201 +8
Lines 15045 15658 +613
Branches 1971 2056 +85
=========================================
+ Hits 4478 4651 +173
- Misses 10415 10850 +435
- Partials 152 157 +5
Continue to review full report at Codecov.
|
Hi @kuhnchris any updates here? :) |
Yeah, as we discussed - making a video/recording to show you and finishing it up ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good @kuhnchris ! I've got a couple suggestions, as well as some questions (and @thelostone-mc has some unanswered questions too). Lets get those addressed, as well as removing the leftover logging statements and style issues. Would also love to see some tests if you've got time! Thanks!
@@ -109,6 +109,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.postComment, name='postComment'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about changing the naming here to just comment
since the post is implied as we're creating a comment resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, can do.
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the goal of this check on new_bounty
?
@@ -624,18 +649,25 @@ def record_bounty_activity(event_name, old_bounty, new_bounty, _fulfillment=None | |||
'increased_bounty', | |||
'worker_rejected', | |||
'bounty_changed'] | |||
logger.info(f"record_bounty_activity > profile at start: {user_profile}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove these extra logging statements before we merge this PR 👍
@@ -728,6 +760,8 @@ def process_bounty_changes(old_bounty, new_bounty): | |||
# record a useraction for this | |||
record_user_action(event_name, old_bounty, new_bounty) | |||
record_bounty_activity(event_name, old_bounty, new_bounty) | |||
# check for review{} in here, create review object, wheeee. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this comment referring to?
) | ||
rating = models.SmallIntegerField(blank=True, default=0) | ||
comment = models.TextField(default='', blank=True) | ||
feedbackType = models.TextField(default='', blank=True, max_length=20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are only two types of feedback: approver
and worker
. If thats the case, what do you think about using the choices
argument here to add a bit of validation and make the admin interface that much nicer? :)
@@ -300,6 +301,42 @@ def new_interest(request, bounty_id): | |||
}) | |||
|
|||
|
|||
@require_POST | |||
def postComment(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use lowercase with underscores style here to match with PEP 8: https://www.python.org/dev/peps/pep-0008/#naming-conventions. Also, since this function handles a POST request as evidenced by the decorator, maybe we should just call it comment
or maybe new_comment
. What do you think?
'sender_profile': profile_id, | ||
'receiver_profile': bountyObj.fulfillments.last().profile, | ||
'rating': feedback_dict.get('rating', '-1'), | ||
'comment': feedback_dict.get('comment', 'No comment.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry about potential script injection issues here due to the untrusted data: OWASP Wiki.
However, maybe santizing that is beyond the scope of V1 of this feature. Lets add a note to make sure we don't forget that this data is untrusted and unsanitized 👍
hey @kuhnchris how goes? ETHDenver is next week.. so hoping to get this in this upcoming monday's deploy. need anything from us? did u see @danlipert 's code comments? |
Closing as we've got the latest at #3709 |
feedback implementation (continuation of #3424)
Description
User-Feedback implementation
Checklist
Affected core subsystem(s)
ui, db, backend, frontend, tips, bounty
Refers/Fixes
Refs: #1464
Testing and Sign-off
/
Contributor
make test
and everything passed!Reviewer
Funder