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

active bounties list in admin and change "too much work" calculation #3486

Merged
merged 4 commits into from
Jul 3, 2019
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
10 changes: 10 additions & 0 deletions app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ class ProfileAdmin(admin.ModelAdmin):
ordering = ['-id']
search_fields = ['email', 'data']
list_display = ['handle', 'created_on']
readonly_fields = ['active_bounties_list']

def active_bounties_list(self, instance):
interests = instance.active_bounties
htmls = []
for interest in interests:
bounty = Bounty.objects.get(interested=interest, current_bounty=True)
htmls.append(f"<a href='{bounty.url}'>{bounty.title_or_desc}</a>")
html = format_html("<BR>".join(htmls))
return html


class VerificationAdmin(admin.ModelAdmin):
Expand Down
5 changes: 5 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,11 @@ def get_profile_referral_code(self):
def job_status_verbose(self):
return dict(Profile.JOB_SEARCH_STATUS)[self.job_search_status]

@property
def active_bounties(self):
active_bounties = Bounty.objects.current().filter(idx_status__in=['open', 'started'])
Copy link
Contributor

Choose a reason for hiding this comment

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

@owocki should this be changed to count only the ones I got approved to work? I know that will introduce a problem if someone apply to work in many things at the same time, but for other side a contributor will be blocked to work if doesn't cancel the "start work" or get rejected by the funder.

return Interest.objects.filter(profile_id=self.pk, bounty__in=active_bounties)

@property
def is_org(self):
try:
Expand Down
4 changes: 1 addition & 3 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ def new_interest(request, bounty_id):
status=401)

num_issues = profile.max_num_issues_start_work
active_bounties = Bounty.objects.current().filter(idx_status__in=['open', 'started'])
num_active = Interest.objects.filter(profile_id=profile_id, bounty__in=active_bounties).count()
is_working_on_too_much_stuff = num_active >= num_issues
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.'),
Expand Down