Skip to content

Commit

Permalink
chore: update active bounties logic
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jan 13, 2020
1 parent e4f3a69 commit 6b31ed5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2551,7 +2551,7 @@ def job_status_verbose(self):

@property
def active_bounties(self):
active_bounties = Bounty.objects.current().filter(idx_status__in=['open', 'started'])
active_bounties = Bounty.objects.current().filter(bounty_state='work_started')
return Interest.objects.filter(profile_id=self.pk, bounty__in=active_bounties)

@property
Expand Down
18 changes: 11 additions & 7 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,17 @@ def new_interest(request, bounty_id):
'success': False},
status=401)

num_issues = profile.max_num_issues_start_work
is_working_on_too_much_stuff = profile.active_bounties.count() >= num_issues
if is_working_on_too_much_stuff:
return JsonResponse({
'error': _(f'You may only work on max of {num_issues} issues at once.'),
'success': False},
status=401)
max_num_issues = profile.max_num_issues_start_work
currently_working_on = profile.active_bounties.count()

if currently_working_on >= max_num_issues:
return JsonResponse(
{
'error': _(f'You cannot work on more than {max_num_issues} issues at once'),
'success': False
},
status=401
)

if profile.no_times_slashed_by_staff():
return JsonResponse({
Expand Down

0 comments on commit 6b31ed5

Please sign in to comment.