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

feat: add is_clr_eligble option to a grant #6923

Merged
merged 1 commit into from
Jun 18, 2020
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
7 changes: 5 additions & 2 deletions app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,16 @@ Vue.component('grants-cart', {
for (let i = 0; i < this.grantData.length; i += 1) {
const verification_required_to_get_match = false;

if (!document.verified && verification_required_to_get_match) {
if (
(!document.verified && verification_required_to_get_match) ||
grantData.is_clr_eligible == 'False'
) {
this.grantData[i].grant_donation_clr_match = 0;
} else {
const grant = this.grantData[i];
const matchAmount = await this.predictCLRMatch(grant);

this.grantData[i].grant_donation_clr_match = matchAmount.toFixed(2);
this.grantData[i].grant_donation_clr_match = matchAmount ? matchAmount.toFixed(2) : 0;
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ class GrantAdmin(GeneralAdmin):
'logo_asset', 'created_on', 'modified_on', 'team_member_list',
'subscriptions_links', 'contributions_links', 'logo', 'logo_svg', 'image_css',
'link', 'clr_matching', 'clr_prediction_curve', 'hidden', 'grant_type', 'next_clr_calc_date', 'last_clr_calc_date',
'metadata', 'categories', 'twitter_handle_1', 'twitter_handle_2', 'view_count'
'metadata', 'categories', 'twitter_handle_1', 'twitter_handle_2', 'view_count', 'is_clr_eligible'
]
readonly_fields = [
'logo_svg_asset', 'logo_asset',
'team_member_list',
'team_member_list', 'clr_prediction_curve',
'subscriptions_links', 'contributions_links', 'link',
'migrated_to', 'view_count'
]
Expand Down
10 changes: 5 additions & 5 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,23 +316,23 @@ def fetch_data(clr_type=None, network='mainnet', clr_start_date=None, clr_end_da
contributions = Contribution.objects.prefetch_related('subscription').filter(match=True, created_on__gte=clr_start_date, created_on__lte=clr_end_date, success=True)

if clr_type == 'tech':
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='tech', link_to_new_grant=None)
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='tech', is_clr_eligible=True, link_to_new_grant=None)
threshold = THRESHOLD_TECH
total_pot = TOTAL_POT_TECH
elif clr_type == 'media':
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='media', link_to_new_grant=None)
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='media', is_clr_eligible=True, link_to_new_grant=None)
threshold = THRESHOLD_MEDIA
total_pot = TOTAL_POT_MEDIA
elif clr_type == 'health':
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='health', link_to_new_grant=None)
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='health', is_clr_eligible=True, link_to_new_grant=None)
threshold = THRESHOLD_HEALTH
total_pot = TOTAL_POT_HEALTH
elif clr_type == 'change':
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='change', link_to_new_grant=None)
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='change', is_clr_eligible=True, link_to_new_grant=None)
threshold = THRESHOLD_CHANGE
total_pot = TOTAL_POT_CHANGE
elif clr_type == 'matic':
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='matic', link_to_new_grant=None)
grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='matic', is_clr_eligible=True, link_to_new_grant=None)
threshold = THRESHOLD_MATIC
total_pot = TOTAL_POT_MATIC
else:
Expand Down
18 changes: 18 additions & 0 deletions app/grants/migrations/0062_grant_is_clr_eligible.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2020-06-18 14:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0061_auto_20200617_1748'),
]

operations = [
migrations.AddField(
model_name='grant',
name='is_clr_eligible',
field=models.BooleanField(default=True, help_text='Is grant eligible for CLR'),
),
]
1 change: 1 addition & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class Meta:
description = models.TextField(default='', blank=True, help_text=_('The description of the Grant.'))
description_rich = models.TextField(default='', blank=True, help_text=_('HTML rich description.'))
reference_url = models.URLField(blank=True, help_text=_('The associated reference URL of the Grant.'))
is_clr_eligible = models.BooleanField(default=True, help_text="Is grant eligible for CLR")
link_to_new_grant = models.ForeignKey(
'grants.Grant',
null=True,
Expand Down
1 change: 0 additions & 1 deletion app/grants/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,3 @@ def process_grant_contribution(self, grant_id, grant_slug, profile_id, package,
thank_you_for_supporting(grant, subscription)

update_grant_metadata.delay(grant_id)

41 changes: 28 additions & 13 deletions app/grants/templates/grants/card/front.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,45 @@ <h2 class="title col-8 font-caption g-bold">
CLR MATCH ROUND 6
</h2>
</div>
<div class="col-6 float-right pr-0">
<div class="col-6 float-right px-0">
<h2 class="font-title font-weight-bold amount pt-1 mb-2">
{{grant.amount_received_in_round|floatformat:2}} DAI
</h2>
<p class="amount mb-2 font-caption font-weight-semibold">
raised from {{grant.positive_round_contributor_count}} contributors
raised from {{grant.positive_round_contributor_count}} contributors
</p>
</div>
<div class="col-6">
<h2 class="font-title font-weight-bold amount pt-1 mb-2">
{{ grant.clr_prediction_curve.0.1|floatformat:0|intcomma|default:0 }} DAI
</h2>
<p class="amount mb-2 font-caption font-weight-semibold">
{% if grant.id in round_5_5_grants %}
Current Round 5.5 Match
{% if grant.is_clr_eligible %}
<h2 class="font-title font-weight-bold amount pt-1 mb-2">
{{ grant.clr_prediction_curve.0.1|floatformat:0|intcomma|default:0 }} DAI
</h2>
<p class="amount mb-2 font-caption font-weight-semibold">
{% if grant.id in round_5_5_grants %}
Current Round 5.5 Match
{% else %}
Estimated CLR Match
{% endif %}
</p>
{% else %}
Estimated CLR Match
<h2 class="font-title font-weight-bold amount pt-1 mb-2">
{{ grant.monthly_amount_subscribed|floatformat:0|intcomma }} DAI
</h2>
<p class="amount mb-2 font-caption font-weight-semibold">MONTHLY RECURRING</p>
{% endif %}
</p>
</div>
</div>
<div class="col-12 pb-3">
{% include 'grants/card/clr_estimate.html' with short=True %}
</div>

{% if grant.is_clr_eligible %}
<div class="col-12 pb-3">
{% include 'grants/card/clr_estimate.html' with short=True %}
</div>
{% else %}
<h2 class="font-subheader text-center amount pt-4 mb-3" style="color:#069953">
NOT ELIGIBLE FOR CLR
</h2>
{% endif%}

<div class="col-12 pb-4">
{% is_team_member grant profile as is_on_team %}
{% if not is_on_team %}
Expand Down
11 changes: 7 additions & 4 deletions app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,14 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
{% comment %} CLR Match Amount {% endcomment %}
<div class="col-2">
<div class="row align-items-center justify-content-between clr-match-box">
<div>
[[grant.grant_donation_clr_match]] DAI
</div>
<img src="{% static 'v2/images/diamonds_high_fiving.gif' %}" alt="Diamonds high-fiving"
<template v-if="grant.is_clr_eligible == 'True'">
<div>[[grant.grant_donation_clr_match]] DAI</div>
<img src="{% static 'v2/images/diamonds_high_fiving.gif' %}" alt="Diamonds high-fiving"
width="20">
</template>
<div v-else class="font-caption font-weight-semibold">
Not Eligible for CLR
</div>
</div>
</div>
{% comment %} Delete Icon {% endcomment %}
Expand Down
34 changes: 12 additions & 22 deletions app/grants/templates/grants/detail/funding.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="card-body">
<div class="row progress-container {% if clr_active %} mb-2 {% endif %} {% if not is_team_member %} mt-4 {% endif %}">
<div class="col-6 text-center text-xl-left offset-xl-0 col-xl-6 mb-xl-0 ">
{% if clr_active or show_clr_card %}
{% if grant.is_clr_eligible and clr_active %}
{% include 'grants/card/clr_match.html' %}
{% else %}
<p class="sub-title font-weight-semibold font-caption mb-1 pt-1">MONTHLY RECURRING</p>
Expand All @@ -35,7 +35,7 @@
<div class="col-6 text-center text-xl-left offset-xl-0 col-xl-6">
<p class="sub-title mb-1 font-weight-semibold font-caption mb-1 pt-1">
ROUND {{ clr_round }}
</p>
</p>
<p class="font-subtitle mb-0">
<span class="font-weight-bold">
{{grant.amount_received_in_round|floatformat:0|intcomma}} DAI
Expand All @@ -44,46 +44,34 @@
{{grant.positive_round_contributor_count}} contributors
</p>
</div>

</div>

{% if grant_is_inactive %}
<button type="button" class="button button--primary shadow-none font-weight-bold button--full py-3" disabled>
{% trans "Grant Has Ended" %}
</button>
</a>
{% else %}

<div class="text-center">
</div>
{% endif %}

{% if clr_active or show_clr_card %}
{% include 'grants/card/clr_estimate.html' %}
{% if grant.is_clr_eligible and clr_active and not grant_is_inactive %}
{% include 'grants/card/clr_estimate.html' %}
{% endif %}

{% if grant_is_inactive %}
<button type="button" class="button button--primary shadow-none font-weight-bold button--full py-3" disabled>
<button type="button" class="mt-3 button button--primary shadow-none font-weight-bold button--full py-3" disabled>
{% trans "Grant Has Ended" %}
</button>


{% elif is_team_member %}
<button class="btn btn-gc-grey cart-btn large font-body font-weight-semibold mt-1 mr-1">
<button class="mt-3 btn btn-gc-grey cart-btn large font-body font-weight-semibold mt-1 mr-1">
<i class="fa fa-stop" aria-hidden="true"></i> Cannot Fund your Own Grant
</button>

{% elif not is_team_member %}

{% if user_non_errored_subscription %}
<a href="{% url 'grants:subscription_cancel' grant.id grant.slug user_subscription.id %}">
<button class="button button--primary button--warning button--full shadow-none font-weight-bold py-3">
<button class="mt-3 button button--primary button--warning button--full shadow-none font-weight-bold py-3">
{% trans "Cancel Your Funding" %}
</button>
</a>
{% elif grant.link_to_new_grant %}
<a href="{{ grant.link_to_new_grant.url }}">
<button class="button button--primary shadow-none font-weight-bold button--full py-3">
<button class="mt-3 button button--primary shadow-none font-weight-bold button--full py-3">
Visit the active grant to fund
</button>
</a>
Expand All @@ -101,8 +89,10 @@

{% if not is_team_member %}
<div class="pt-2 mb-1">
<div class="float-right">
<a id="flag" href="#" data-href="/grants/flag/{{grant.id}}">Flag <i class="far fa-flag"></i></a>
<div class="text-right">
<a id="flag" href="#" data-href="/grants/flag/{{grant.id}}" class="font-caption font-weight-semibold px-3">
Flag <i class="ml-2 far fa-flag"></i>
</a>
</div>
</div>
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions app/grants/templates/grants/shared/hidden_inputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
<input type="hidden" id="grant_logo" name="grant_logo" value="{% if grant.logo and grant.logo.url %}{{ grant.logo.url }}{% else %}{% with grant_logo='v2/images/grants/logos/' id=grant.id|modulo:3 %} {% static grant_logo|addstr:id|add:'.png' %} {% endwith %} {% endif %}">
<input type="hidden" id="grant_clr_prediction_curve" name="grant_clr_prediction_curve" value="{{ grant.clr_prediction_curve }}">
<input type="hidden" id="grant_image_css" name="grant_image_css" value="{{ grant.image_css }}">
<input type="hidden" id="is_clr_eligible" name="is_clr_eligible" {% if grant.is_clr_eligible %} value="{{ grant.is_clr_eligible }}" {% endif %}>
3 changes: 0 additions & 3 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
total_clr_pot = 175000
clr_round = 6
clr_active = True
show_clr_card = True
# Round Schedule
# from canonical source of truth https://gitcoin.co/blog/gitcoin-grants-round-4/
# Round 5 - March 23th — April 7th 2020
Expand Down Expand Up @@ -449,7 +448,6 @@ def grants_by_grant_type(request, grant_type):
'grant_amount': grant_amount,
'total_clr_pot': total_clr_pot,
'clr_active': clr_active,
'show_clr_card': show_clr_card,
'sort_by_index': sort_by_index,
'clr_round': clr_round,
'show_past_clr': show_past_clr,
Expand Down Expand Up @@ -612,7 +610,6 @@ def grant_details(request, grant_id, grant_slug):
'activity_count': activity_count,
'contributors': contributors,
'clr_active': clr_active,
'show_clr_card': show_clr_card,
'is_team_member': is_team_member,
'voucher_fundings': voucher_fundings,
'is_unsubscribed_from_updates_from_this_grant': is_unsubscribed_from_updates_from_this_grant,
Expand Down