Skip to content

Commit

Permalink
feat: grant sidebar (#9654)
Browse files Browse the repository at this point in the history
* feat: side round support + banner tweaks

* add migration

* chore: cleanup template

* feat: revamp sidebar on grant detail

* address feedback

* update URL

* improve if check
  • Loading branch information
thelostone-mc authored Nov 23, 2021
1 parent 89f50d6 commit 0cd2af9
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 87 deletions.
1 change: 1 addition & 0 deletions app/assets/v2/js/grants/_detail-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Vue.mixin({
vm.grant.verified = false;
}
vm.grant_twitter_handle_1 = vm.grant.twitter_handle_1;
vm.grant.is_idle = false;
vm.$root.$emit('bv::toggle::collapse', 'sidebar-grant-edit');
_alert('Updated grant.', 'success');

Expand Down
11 changes: 10 additions & 1 deletion app/grants/models/grant.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,14 @@ def url(self):
def get_absolute_url(self):
return self.url


@property
def is_idle(self):
"""Return if grants is idle."""
three_months_ago = timezone.now() - timezone.timedelta(days=90)
return (self.last_update <= three_months_ago)


@property
def contract(self):
"""Return grants contract."""
Expand Down Expand Up @@ -919,7 +927,8 @@ def repr(self, user, build_absolute_uri):
'link_to_new_grant': self.link_to_new_grant.url if self.link_to_new_grant else self.link_to_new_grant,
'region': {'name':self.region, 'label':self.get_region_display()} if self.region and self.region != 'null' else None,
'has_external_funding': self.has_external_funding,
'active_round_names': active_round_names
'active_round_names': active_round_names,
'is_idle': self.is_idle
}

def favorite(self, user):
Expand Down
221 changes: 145 additions & 76 deletions app/grants/templates/grants/detail/template-grant-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ <h2 class="text-secondary">+$[[ grant?.clr_prediction_curve?.[0]?.[1] || 0 | rou
<a href="https://gitcoin.co/blog/gitcoin-grants-quadratic-funding-for-the-world/" rel="noopener noreferrer" target="_blank">Learn more</a>
</p>
<p>
This grant is currently part of [[ grant?.active_round_names.length ]] active matching rounds:
This grant is currently part of [[ grant?.active_round_names.length ]] active matching round
<template v-if="grant?.active_round_names.length > 1">s</template>:
<dl class="mt-0">
<li v-for="round_name in grant.active_round_names">[[round_name]]</li>
</dl>
Expand All @@ -345,45 +346,117 @@ <h3>About</h3>

<!-- Grant Management -->
<div class="grant-managment mt-4 mt-md-0">
<div class="my-0 mx-0" v-if="grant.admin_message">
<div class="bs-alert alert alert-warning p-2 d-flex">
<div class="text-center w-100">
<i class="fas fa-exclamation-triangle verification__warning__icon mr-1 my-2 d-inline-block" style="font-size:1rem"></i>
<div class="d-inline-block uppercase font-weight-semibold w-100">
[[grant.admin_message]]
</div>
</div>
</div>
</div>
<div class="my-0 mx-0" v-if="grant.active && !grant.verified">
<div class="bs-alert alert alert-warning p-2 d-flex">
<div class="text-center">
<i class="fas fa-exclamation-triangle verification__warning__icon mr-1 my-2 d-inline-block" style="font-size:1rem"></i>
<div class="d-inline-block uppercase">
<span class="font-weight-semibold">Warning:</span> This grant has not verified their ownership of the twitter account listed.
</div>
<template v-if="grant.is_on_team && user_code">
<div class="my-2 d-inline-block text-center w-100">
<b-button v-b-modal.modal-start-twitter-verification variant="primary">
<i class="fab fa-twitter mr-2"></i>
Verify Grant
</b-button>
<br/>
<span class="small px-2">OR</span>
<a class="d-inline-block font-caption pt-2" target="_blank" href="https://github.com/gitcoinco/web/issues/new?assignees=&labels=help%20wanted&template=custom.md&title=Verify%20Grant%20Issue">SUBMIT SUPPORT REQUEST</a>.
</div>
<b-card>

<!-- Admin Message -->
<template v-if="grant.admin_message">
<b-card-text>
<p class="font-weight-semibold mb-2">
<i class="fal fa-exclamation-circle mr-1 text-danger"></i>
Message from gitcoin
</p>
[[grant.admin_message]]
</b-card-text>
<hr class="my-4">
</template>

<!-- Inactive Grant -->
<template v-if="!grant.active && !grant.verified">
<b-card-text>
<p class="font-weight-semibold mb-2">
<i class="fal fa-exclamation-circle mr-1"></i>
Your grant is inactive
</p>
Our team reviews each grant before it goes live on the website.
This process usually takes 1-2 days.
</b-card-text>

<a class="btn btn-block btn-primary" href="https://support.gitcoin.co/kb/article/79-why-isn-t-my-grant-active/" rel="noopener noreferrer">
Read Grant Approval Process
</a>

<hr class="my-4">

</template>

<!-- Verify Grant -->
<template v-if="grant.active && !grant.verified">
<b-card-text>
<p class="font-weight-semibold mb-2">
<i class="fal fa-exclamation-circle mr-1 text-danger"></i>
Unverified on twitter
</p>
This grant has not verified their ownership of the twitter account listed.
</b-card-text>

<div v-if="grant.is_on_team" class="text-center">

<template v-if="user_code">
<b-button v-b-modal.modal-start-twitter-verification variant="primary" class="btn btn-block btn-primary">
<i class="fab fa-twitter mr-2"></i>
Verify Grant
</b-button>
</template>
<template v-else-if="grant.is_on_team && !user_code">
<div class="my-2 font-weight-semibold text-center">
<p class="mb-1">Visit grant details page to verify the grant.</p>
<a :href="grant.details_url">Go to grant details page</a>
</div>

<template v-else>
<p class="mb-1">Visit grant details page to verify the grant.</p>
<a :href="grant.details_url">Go to grant details page</a>
</template>

</div>
</div>
</div>
<button class="btn btn-block btn-primary" @click="editGrantModal()" v-if="fullview && (grant.active && grant.is_on_team) || fullview && (grant.active && isStaff)">Edit Grant</button>
<a class="btn btn-block btn-primary" :href="grant.details_url" target="_blank" v-else-if="!fullview && (grant.active && grant.is_on_team)">Edit Grant</a>

<hr class="my-4">
</template>

<!-- Idle Grant -->
<template v-if="grant.active && grant.is_on_team && grant.is_idle">
<b-card-text>
<p class="font-weight-semibold mb-2">
<i class="fal fa-exclamation-circle mr-1 text-danger"></i>
Update and make your grant visible
</p>
Your grant is hidden from the explorer because it hasn’t been updated for more than 3 months.
Update your grant to make it visible.
</b-card-text>
<button class="btn btn-block btn-primary" @click="editGrantModal()" v-if="fullview">Update Grant</button>
<a class="btn btn-block btn-primary" :href="grant.details_url" target="_blank" v-else>Update Grant</a>
<hr class="my-4">
</template>


<!-- L2 contributions -->
<template v-if="grant.active && grant.is_on_team && grant.tenants.includes('ETH')">
<b-card-text>
<p class="font-weight-semibold mb-2">
<i class="fal fa-wallet mr-1"></i>
You’ve received L2 contributions
</p>
Some of your grant funds may be in L2 (zkSync or Polygon).
Read more on how to withdraw from L2 wallets.
</b-card-text>
<a class="btn btn-block btn-primary" rel="noopener noreferrer" href="https://support.gitcoin.co/kb/article/75-how-do-i-withdraw-my-funds-from-an-l2-layer-zksync-and-or-polygon-matic/" target="_blank">
Read L2 Withdrawal guide
</a>
</template>


<!-- Edit Grant Button -->
<template v-if="grant.active && !grant.is_idle && (grant.is_on_team || isStaff)">
<hr class="my-4">

<b-card-text>
<p class="font-weight-semibold mb-2">
<i class="fal fa-edit mr-1"></i>
Keep your grant up to date
</p>
Let your grant contributors know about your project and progress.
</b-card-text>
<button class="btn btn-block btn-primary" @click="editGrantModal()" v-if="fullview">Edit Grant</button>
<a class="btn btn-block btn-primary" :href="grant.details_url" target="_blank" v-else>Edit Grant</a>
</template>

</b-card>

</div>

<!-- CLR details and Add-to/remove-from cart -->
Expand Down Expand Up @@ -418,48 +491,44 @@ <h3>About</h3>
</template>
</div>

<div class="col-12 mt-2">
<div class="row text-grey-400 font-smaller-1">

<!-- Grants Fav-->
<div class="col-md-4">
<template v-if="isUserLogged">
<button @click="toggleFollowingGrant(grant.id, $event)"
v-b-tooltip.hover.bottom="!grant.favorite ? 'follow' : 'unfollow'"
:class="`pl-0 btn btn-link mx-0 my-auto ${!grant.favorite ? 'text-grey-300' : 'text-primary'}`"
:data-grant="grant.id"
>
<i :class="`${!grant.favorite ? 'far' : 'fa' } fa-star`" ></i>
Follow
</button>
</template>
</div>
<div class="d-flex justify-content-between mt-2 text-grey-400 font-smaller-1">

<!-- Grants Rules-->
<div class="col-md-8 text-right">
<div class="d-inline font-smaller-2 cursor-pointer" id="popover-target-1" style="width: 65px;">
<i class="fas fa-info-circle mr-2"></i>
Rules
</div>
<b-popover target="popover-target-1" triggers="hover" placement="left">
<template #title>Rules</template>
<p>Matching will not be applied if the rules are broken. Rules TLDR:</p>
<ul class="pl-3">
<li><b>DO NOT</b> offer anyone a quid-pro-quo for a contribution.</li>
<li><b>DO NOT</b> make up a new identity to contribute.</li>
<li><b>DO NOT</b> try to falsify a contribution.</li>
</ul>
If you see someone breaking the rules, please use 'Flag Grant' to report them.
</b-popover>

<!-- Grants Flag-->
<button @click="flag" class="btn ml-1 px-1" style="width: 65px;">
<i class="text-grey-400 fas fa-flag mr-2"></i>
Flag
</button>
</div>
<!-- Grants Fav-->
<div v-if="isUserLogged">
<button @click="toggleFollowingGrant(grant.id, $event)"
v-b-tooltip.hover.bottom="!grant.favorite ? 'follow' : 'unfollow'"
:class="`pl-0 btn btn-link mx-0 my-auto ${!grant.favorite ? 'text-grey-300' : 'text-primary'}`"
:data-grant="grant.id"
>
<i :class="`${!grant.favorite ? 'far' : 'fa' } fa-star`" ></i>
Follow
</button>
</div>

<!-- Grants Rules-->
<div>
<div class="d-inline font-smaller-2 cursor-pointer" id="popover-target-1" style="width: 65px;">
<i class="fas fa-info-circle mr-2"></i>
Rules
</div>
<b-popover target="popover-target-1" triggers="hover" placement="left">
<template #title>Rules</template>
<p>Matching will not be applied if the rules are broken. Rules TLDR:</p>
<ul class="pl-3">
<li><b>DO NOT</b> offer anyone a quid-pro-quo for a contribution.</li>
<li><b>DO NOT</b> make up a new identity to contribute.</li>
<li><b>DO NOT</b> try to falsify a contribution.</li>
</ul>
If you see someone breaking the rules, please use 'Flag Grant' to report them.
</b-popover>

<!-- Grants Flag-->
<button v-if="!grant.is_on_team" @click="flag">
<i class="text-grey-400 fas fa-flag mr-2"></i>
Flag
</button>
</div>

</div>

</div>
Expand Down
10 changes: 0 additions & 10 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,6 @@ def grants_by_grant_type(request, grant_type):
'round_end': round_end_date,
'next_round_start': round_start_date,
'now': timezone.now(),
# 'mid_back': mid_back,
# 'bottom_back': bottom_back,
'card_desc': f'{live_now}',
'avatar_url': request.build_absolute_uri(static('v2/images/twitter_cards/default_grants.png')),
'card_type': 'summary_large_image',
Expand All @@ -1065,11 +1063,6 @@ def grants_by_grant_type(request, grant_type):
'can_pin': can_pin(request, what),
'pinned': pinned,
'target': f'/activity?what=all_grants',
# 'styles': {
# 'bg': bg,
# 'bg_size': bg_size,
# 'bg_color': bg_color
# },
'grant_bg': get_branding_info(request),
'announcement': Announcement.objects.filter(key='grants', valid_from__lt=timezone.now(), valid_to__gt=timezone.now()).order_by('-rank').first(),
'keywords': get_keywords(),
Expand Down Expand Up @@ -2237,9 +2230,6 @@ def bulk_fund(request):
})
continue

active_subscription = Subscription.objects.select_related('grant').filter(
grant=grant_id, active=True, error=False, contributor_profile=request.user.profile, is_postive_vote=True
)

try:
payload = {
Expand Down

0 comments on commit 0cd2af9

Please sign in to comment.