Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
closes #1027
Browse files Browse the repository at this point in the history
  • Loading branch information
dmorina committed Dec 13, 2017
1 parent cfea191 commit 3235056
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crowdsourcing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def filter_by_boomerang(self, worker, sort_by='-boomerang'):
ELSE worker_rating + 0.1 * worker_avg_rating END worker_rating
FROM get_worker_ratings(%(worker_id)s)) worker_ratings
ON worker_ratings.requester_id = ratings.owner_id
AND (worker_ratings.worker_rating >= ratings.min_rating or p.enable_boomerang is FALSE)
AND (worker_ratings.worker_rating >= ratings.min_rating or p.enable_boomerang is FALSE
or p.owner_id = %(worker_id)s)
WHERE coalesce(p.deadline, NOW() + INTERVAL '1 minute') > NOW() AND p.status = 3 AND deleted_at IS NULL
AND (requester.is_denied = FALSE OR p.enable_blacklist = FALSE)
AND is_worker_qualified(quals.expressions, (%(worker_data)s)::JSON)
Expand Down
3 changes: 2 additions & 1 deletion crowdsourcing/permissions/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def has_permission(self, request, view):
rating = cursor.fetchall()
cursor.close()
avg_rating = rating[0][1] if len(rating) and len(rating[0]) and rating[0][1] is not None else 1.99
if avg_rating < project['min_rating'] and project['enable_boomerang']:
if avg_rating < project['min_rating'] and project['enable_boomerang'] and \
request.user.id != project['owner_id']:
raise PermissionDenied(detail='You don\'t have permission to access this project.')
entry = WorkerAccessControlEntry.objects.filter(group__requester_id=project['owner_id'],
group__is_global=True, worker=request.user).first()
Expand Down

0 comments on commit 3235056

Please sign in to comment.