diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index f856aa5b397..8ab4eea4580 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -5,6 +5,9 @@ load_tokens(); var localStorage = window.localStorage ? window.localStorage : {}; const quickstartURL = document.location.origin + '/bounty/quickstart'; + +let params = (new URL(document.location)).searchParams; + const FEE_PERCENTAGE = document.FEE_PERCENTAGE / 100.0; var new_bounty = { @@ -40,9 +43,15 @@ $('.select2-tag__choice').on('click', function() { }); const getSuggestions = () => { + let queryParams = {}; + + queryParams.keywords = $('#keywords').val(); + queryParams.invite = params.get('invite') || ''; + + let searchParams = new URLSearchParams(queryParams); const settings = { - url: `/api/v0.1/get_suggested_contributors?keywords=${$('#keywords').val()}`, + url: `/api/v0.1/get_suggested_contributors?${searchParams}`, method: 'GET', processData: false, dataType: 'json', @@ -53,7 +62,8 @@ const getSuggestions = () => { let groups = { 'contributors': 'Recently worked with you', 'recommended_developers': 'Recommended based on skills', - 'verified_developers': 'Verified contributors' + 'verified_developers': 'Verified contributors', + 'invites': 'Invites' }; let options = Object.entries(response).map(([ text, children ]) => ( @@ -68,8 +78,12 @@ const getSuggestions = () => { } obj.children.forEach((children, childIndex) => { - children.text = children.fulfiller_github_username || children.user__profile__handle; + children.text = children.fulfiller_github_username || children.user__profile__handle || children.handle; children.id = generalIndex; + if (obj.text == 'Invites') { + children.selected = true; + $('#reserve-section').collapse('show'); + } generalIndex++; }); return obj; @@ -275,7 +289,22 @@ $(function() { setUsdAmount(); } - userSearch('#reservedFor', false); + if (params.get('reserved')) { + $('#reserve-section').collapse('show'); + } + + userSearch( + '#reservedFor', + // show address + false, + // theme + '', + // initial data + params.get('reserved') ? [params.get('reserved')] : [], + // allowClear + true + ); + }); @@ -828,7 +857,6 @@ const populateBountyTotal = () => { }; let isPrivateRepo = false; -let params = (new URL(document.location)).searchParams; const toggleCtaPlan = (value) => { if (value === 'private') { diff --git a/app/assets/v2/js/users.js b/app/assets/v2/js/users.js index 8b1d133137a..658c72c9ad9 100644 --- a/app/assets/v2/js/users.js +++ b/app/assets/v2/js/users.js @@ -87,8 +87,8 @@ Vue.mixin({ let getBounties = fetchData(apiUrlBounties, 'GET'); $.when(getBounties).then((response) => { + vm.isFunder = response.is_funder; vm.funderBounties = response.data; - console.log(vm.funderBounties); }); }, @@ -158,6 +158,7 @@ if (document.getElementById('gc-users-directory')) { bottom: false, params: {}, funderBounties: [], + isFunder: false, bountySelected: null, userSelected: [], showModal: false, diff --git a/app/dashboard/templates/dashboard/users.html b/app/dashboard/templates/dashboard/users.html index 666275c37fc..cd142c3849c 100644 --- a/app/dashboard/templates/dashboard/users.html +++ b/app/dashboard/templates/dashboard/users.html @@ -125,6 +125,12 @@
+ +
[[ user.data.name || user.handle ]] @@ -179,6 +185,7 @@
+ Fund Bounty
@@ -200,7 +207,9 @@
Invite User to Bounty
- Select a bounty +
+ Select a bounty or create a new one +
diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 4f37ffb0913..0200119cc97 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -879,8 +879,14 @@ def get_user_bounties(request): params = dict() results = [] - open_bounties = Bounty.objects.current().filter(bounty_owner_github_username__iexact=profile.handle, network=network) \ - .exclude(idx_status='cancelled').exclude(idx_status='done') + all_bounties = Bounty.objects.current().filter(bounty_owner_github_username__iexact=profile.handle, network=network) + + if len(all_bounties) > 0: + is_funder = True + else: + is_funder = False + + open_bounties = all_bounties.exclude(idx_status='cancelled').exclude(idx_status='done') for bounty in open_bounties: bounty_json = {} bounty_json = bounty.to_standard_dict() @@ -891,6 +897,7 @@ def get_user_bounties(request): # raise Http404 print(open_bounties) params['data'] = json.loads(json.dumps(results, default=str)) + params['is_funder'] = is_funder return JsonResponse(params, status=200, safe=False) @@ -2405,7 +2412,10 @@ def new_bounty(request): @csrf_exempt def get_suggested_contributors(request): previously_worked_developers = [] + users_invite = [] keywords = request.GET.get('keywords', '').split(',') + invitees = [int(x) for x in request.GET.get('invite', '').split(',') if x] + if request.user.is_authenticated: previously_worked_developers = BountyFulfillment.objects.prefetch_related('bounty', 'profile')\ .filter( @@ -2425,11 +2435,19 @@ def get_suggested_contributors(request): verified_developers = UserVerificationModel.objects.filter(verified=True).values('user__profile__handle', 'user__profile__id') + if invitees: + invitees_filter = Q() + for invite in invitees: + invitees_filter = invitees_filter | Q(pk=invite) + + users_invite = Profile.objects.filter(invitees_filter).values('id', 'handle', 'email').distinct() + return JsonResponse( { 'contributors': list(previously_worked_developers), 'recommended_developers': list(recommended_developers), - 'verified_developers': list(verified_developers) + 'verified_developers': list(verified_developers), + 'invites': list(users_invite) }, status=200)