-
-
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
Changes from 1 commit
f662ff1
1635061
e7d9b13
19729c9
ca6644c
3323668
fdcf1de
4ccbda7
bc7e5b1
f39645e
9ed8d67
38f1364
dfa7783
370237c
19d6184
822c107
7ceb038
fe013c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -300,6 +300,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 commentThe 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 |
||
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.'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
|
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