Skip to content

Commit

Permalink
Merge pull request #4478 from gitcoinco/create-work
Browse files Browse the repository at this point in the history
Propose work
  • Loading branch information
thelostone-mc authored May 28, 2019
2 parents c5809b9 + 2062d0f commit 18d4339
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 10 deletions.
38 changes: 33 additions & 5 deletions app/assets/v2/js/pages/new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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',
Expand All @@ -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 ]) => (
Expand All @@ -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;
Expand Down Expand Up @@ -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
);


});

Expand Down Expand Up @@ -828,7 +857,6 @@ const populateBountyTotal = () => {
};

let isPrivateRepo = false;
let params = (new URL(document.location)).searchParams;

const toggleCtaPlan = (value) => {
if (value === 'private') {
Expand Down
3 changes: 2 additions & 1 deletion app/assets/v2/js/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

},
Expand Down Expand Up @@ -158,6 +158,7 @@ if (document.getElementById('gc-users-directory')) {
bottom: false,
params: {},
funderBounties: [],
isFunder: false,
bountySelected: null,
userSelected: [],
showModal: false,
Expand Down
11 changes: 10 additions & 1 deletion app/dashboard/templates/dashboard/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
<div class="grid-4">
<div v-for="user in users" class="card card-user shadow-sm border-0" :key="user.id">
<div class="d-flex flex-column py-1 bg-lightblue">
<button class="btn position-absolute align-self-end" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-ellipsis-v"></i></button>
<div class="dropdown-menu dropdown-menu-right">
<a :href="`/funding/new?invite=${ user.id }`" target="_blank" class="dropdown-item">Fund bounty</a>
<div class="dropdown-divider"></div>
<a :href="`/profile/${ user.handle }`" class="dropdown-item" target="_blank">View profile</a>
</div>
<img class="rounded-circle shadow-sm mx-auto mt-n5 mb-3 bg-white" width="113" height="113" :src="`/dynamic/avatar/${ user.handle }`"/>
<h5 class="text-center card-user_name">
[[ user.data.name || user.handle ]]
Expand Down Expand Up @@ -179,6 +185,7 @@ <h5 class="text-center card-user_name">
</div>
<div class="text-center mt-2">
<button v-if="funderBounties.length" data-toggle="modal" data-target="#userModal" class="btn btn-sm btn-gc-blue" @click="openBounties(user)">Invite to Bounty</button>
<a v-if="isFunder && !funderBounties.length" :href="`/funding/new?invite=${ user.id }`" target="_blank" class="btn btn-sm btn-gc-blue">Fund Bounty</a>
</div>
</div>
</div>
Expand All @@ -200,7 +207,9 @@ <h6 class="font-weight-bold mb-3">Invite User to Bounty</h6>
</div>
<div slot="body" v-if="userSelected.handle">
<div v-if="funderBounties.length">
<b>Select a bounty</b>
<div class="my-2 text-center">
<b>Select a bounty</b> or <a :href="`/funding/new?invite=${ userSelected.id }`" target="_blank" class="font-weight-bold">create a new one</a>
</div>
<div class="bounties-box">
<div v-for="bounty in funderBounties" :key="bounty.id" @click="bountySelected = bounty" v-bind:class="{ 'btn-gc-blue': bountySelected && bounty.id === bountySelected.id }" class="bounty-select py-2 px-3 border-bottom d-flex align-items-center">
<img :src="`/dynamic/avatar/${ bounty.funding_organisation || bounty.bounty_owner_github_username }`" class="rounded-circle flex-shrink-0" width="30" height="30">
Expand Down
24 changes: 21 additions & 3 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)


Expand Down Expand Up @@ -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(
Expand All @@ -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)

Expand Down

0 comments on commit 18d4339

Please sign in to comment.