Skip to content
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

dont let users submit work unless they've started work #2799

Merged
merged 2 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions app/app/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ def save_profile(backend, user, response, request, *args, **kwargs):
if handle in settings.BLOCKED_USERS:
raise SuspiciousOperation('You cannot login')

if not user.active:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbeacom this look ok?

raise SuspiciousOperation('You cannot login')

sync_profile(handle, user, hide_profile=False)
setup_lang(request, user)
12 changes: 12 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,18 @@ def is_funder(self, handle):
"""
return handle.lower().lstrip('@') == self.bounty_owner_github_username.lower().lstrip('@')

def has_started_work(self, handle, pending=False):
"""Determine whether or not the profile has started work

Args:
handle (str): The profile handle to be compared.

Returns:
bool: Whether or not the user has started work.

"""
return self.interested.filter(pending=pending, profile__handle=handle).exists()

@property
def absolute_url(self):
return self.get_absolute_url()
Expand Down
3 changes: 3 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from django.contrib import messages
from django.contrib.auth.models import User
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import redirect
Expand Down Expand Up @@ -743,6 +744,8 @@ def fulfill_bounty(request):

"""
bounty = handle_bounty_views(request)
if not bounty.has_started_work(request.user.username):
raise PermissionDenied
params = get_context(
ref_object=bounty,
github_username=request.GET.get('githubUsername'),
Expand Down