Skip to content

[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

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added postComment, new PostComment target, feedback
  • Loading branch information
kuhnchris committed Jan 20, 2019
commit 19d618438b17c1f70a354185257d914229f16130
1 change: 1 addition & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,7 @@ def __str__(self):
"""Return the string representation of a Bounty."""
return f'<BlockedUser: {self.handle}>'


class FeedbackEntry(SuperModel):

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

bounty = models.ForeignKey(
'dashboard.Bounty',
Expand Down
38 changes: 37 additions & 1 deletion app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

from app.utils import clean_str, ellipses
from avatar.utils import get_avatar_context_for_user
from dashboard.utils import ProfileHiddenException, ProfileNotFoundException, profile_helper
from dashboard.utils import ProfileHiddenException, ProfileNotFoundException, profile_helper, FeedbackEntry
from economy.utils import convert_token_to_usdt
from eth_utils import to_checksum_address, to_normalized_address
from gas.utils import recommend_min_gas_price_to_confirm_in_time
Expand Down Expand Up @@ -300,6 +300,42 @@ def new_interest(request, bounty_id):
})


@require_POST
def postComment(request):
Copy link
Contributor

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?

profile_id = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None
if profile_id is None:
return JsonResponse({
'success': False,
'msg': '',
})

sbid = request.POST.get('standard_bounties_id')
bountyObj = Bounty.objects.filter(standard_bounties_id=sbid).first()
fbAmount = FeedbackEntry.objects.filter(sender_profile=profile_id, feedbackType='approver', bounty=bountyObj).count()
if fbAmount > 0:
return JsonResponse({
'success': False,
'msg': 'There is already a approval comment',
})
feedback_dict = request.POST.get('review',{})
kwargs = {
'bounty': bountyObj,
'sender_profile': profile_id,
'receiver_profile': bountyObj.fulfillments.last().profile,
'rating': feedback_dict.get('rating', '-1'),
'comment': feedback_dict.get('comment', 'No comment.'),
Copy link
Contributor

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 👍

'feedbackType': feedback_dict.get('feedbackType','approver')
}

e = FeedbackEntry.objects.create(**kwargs)
e.save()
return JsonResponse({
'success': False,
'msg': 'Finished.',
'feedbackEntry': e
})


@csrf_exempt
@require_POST
def remove_interest(request, bounty_id):
Expand Down