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

fix bulk invite and query #5428

Merged
merged 1 commit into from
Nov 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
16 changes: 15 additions & 1 deletion app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,22 @@ class ToolVoteAdmin(admin.ModelAdmin):


class BountyInvitesAdmin(admin.ModelAdmin):
raw_id_fields = ['bounty']
raw_id_fields = ['bounty', 'inviter', 'invitee']
ordering = ['-id']
readonly_fields = [ 'from_inviter', 'to_invitee']
list_display = [ 'id', 'from_inviter', 'to_invitee', 'bounty_url']

def bounty_url(self, obj):
bounty = obj.bounty.first()
return format_html("<a href={}>{}</a>", mark_safe(bounty.url), mark_safe(bounty.url))

def from_inviter(self, obj):
"""Get the profile handle."""
return "\n".join([p.username for p in obj.inviter.all()])

def to_invitee(self, obj):
"""Get the profile handle."""
return "\n".join([p.username for p in obj.invitee.all()])


class InterestAdmin(admin.ModelAdmin):
Expand Down
25 changes: 13 additions & 12 deletions app/dashboard/templates/dashboard/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,25 @@
<div class="pb-4 border-bottom form-group">
<label for="bounty-completed" class="font-weight-bold">Bounties Completed</label>
<div class="form__select2">
<select2 v-model="params.bounties_completed" data-minimum-results-for-search="Infinity" class="form-control">
<select2 v-model.trim="params.bounties_completed" data-tags="true" class="form-control">
<option value="" selected="true">All</option>
<option value="0,5">0-5</option>
<option value="5,10">5-10</option>
<option value="10,15">10-15</option>
<option value="15,20">15-20</option>
<option value="0,5">0,5</option>
<option value="5,10">5,10</option>
<option value="10,15">10,15</option>
<option value="15,20">15,20</option>
</select2>
</div>
</div>
<div class="pb-4 border-bottom form-group">
<label for="leaderboard_rank" class="font-weight-bold">Leaderboard Rank</label>
<div class="form__select2">
<select2 v-model="params.leaderboard_rank" data-minimum-results-for-search="Infinity" class="form-control">
<select2 v-model.trim="params.leaderboard_rank" data-tags="true" class="form-control">
<option value="" selected="true">All</option>
<option value="0,5">0-5</option>
<option value="5,10">5-10</option>
<option value="10,15">10-15</option>
<option value="15,20">15-20</option>
<option value="1,5">1,5</option>
<option value="5,10">5,10</option>
<option value="10,15">10,15</option>
<option value="15,20">15,20</option>
<option value="20,25">20,25</option>
</select2>
</div>
</div>
Expand Down Expand Up @@ -127,7 +128,7 @@
<p class="font-body mx-2 mb-2 mt-4">
<span class="font-weight-bold">[[ numUsers ]]</span> users found
</p>
<button v-show="numUsers > 0" data-toggle="modal" data-target="#inviteAll" :disabled="!(params.skills && params.skills.length)" class="font-body btn btn-gc-blue ml-2" id="bulk-invite-modal">
<button v-show="numUsers > 0" data-toggle="modal" data-target="#inviteAll" :disabled="!(params && (Object.keys(params).length > 1))" class="font-body btn btn-gc-blue ml-2" id="bulk-invite-modal">
Invite all to bounty
</button>
{% endif %}
Expand Down Expand Up @@ -300,7 +301,7 @@ <h6 class="font-weight-bold mb-3">Invite [[numUsers]] Users to the Bounty</h6>
{% include 'shared/analytics.html' %}
{% include 'shared/footer_scripts.html' %}
{% include 'shared/footer.html' %}


<script>
$('body').bootstrapTooltip({
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ def bulk_invite(request):
organisation = request.POST.get('params[organisation]', '')
bounty_id = request.POST.get('bountyId')

if None in (skills, bounty_id, inviter):
if None in (bounty_id, inviter):
return JsonResponse({'success': False}, status=400)

bounty = Bounty.objects.current().get(id=int(bounty_id))
Expand Down