Skip to content

Commit

Permalink
Merge pull request #5428 from gitcoinco/fix/bulk-invites
Browse files Browse the repository at this point in the history
fix bulk invite and query
  • Loading branch information
thelostone-mc authored Nov 3, 2019
2 parents 84c642b + 2b6cc68 commit 1fc113a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
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

0 comments on commit 1fc113a

Please sign in to comment.