Skip to content

Commit

Permalink
Merge pull request #5343 from thelostone-mc/buz
Browse files Browse the repository at this point in the history
increase_bounty: add coupon code
  • Loading branch information
thelostone-mc authored Oct 22, 2019
2 parents 6721d88 + 33511f3 commit cc2d4f2
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 110 deletions.
5 changes: 3 additions & 2 deletions app/assets/v2/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ input[type=text].loading {
}

#primary_form {
max-width: 550px;
max-width: 550px; /* TODO: REMOVE */
margin: 0 auto;
padding: 0 2em;
}
Expand All @@ -501,7 +501,8 @@ input[type=text].loading {
}

.submit_bounty #primary_form,
.fulfill_bounty #primary_form {
.fulfill_bounty #primary_form,
.increase_bounty #primary_form {
max-width: none;
}

Expand Down
5 changes: 3 additions & 2 deletions app/assets/v2/css/submit_bounty.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* stylelint-disable selector-pseudo-class-no-unknown */

.submit_bounty .submit_bounty_content,
.fulfill_bounty .submit_bounty_content {
.fulfill_bounty .submit_bounty_content,
.increase_bounty .submit_bounty_content {
background-color: #f2f6f9;
}

Expand Down Expand Up @@ -42,7 +43,7 @@ input:read-only {
text-transform: none;
}

#primary_form .font-subheader {
#primary_form #fee-section .font-subheader {
color: #666666;
font-weight: bold;
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/pages/increase_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $(document).ready(function() {
e.preventDefault();
loading_button($(this));

var issueURL = $('input[name=issueURL]').val();
var issueURL = $('#issueURL').html();
var amount = $('input[name=amount]').val();
var tokenAddress = $('select[name=denomination]').val();

Expand Down
200 changes: 104 additions & 96 deletions app/dashboard/templates/bounty/increase.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,16 @@
<head>
{% include 'shared/head.html' %}
{% include 'shared/cards.html' %}
<style>
#primary_form {
max-width: 40rem;
}
</style>
<link rel="stylesheet" href={% static "v2/css/submit_bounty.css" %}>
</head>

<body class="interior {{active}} g-font-muli">
<body class="interior {{active}} g-font-muli" style="background-color: #FFFFFF;">
{% include 'shared/tag_manager_2.html' %}
<div class="container-fluid header dash">
{% include 'shared/top_nav.html' with class='d-md-flex' %}
{% include 'shared/nav.html' %}
</div>
<div class="container-fluid">
<div class="container-fluid submit_bounty_content">
<div class="row no-gutters metamask-banner">
<div class="col-12">
{% include 'shared/no_issue_error.html' with page='submit_bounty' %}
Expand All @@ -48,110 +43,120 @@
</div>
{% include 'shared/success_container.html' %}
<div class="row content">
<div class="col-12 body">
<div class="col-12">
<div class="row font-smaller-2" id="form_container">
<div id="robot_error" class="hidden">
<img src="{% static "v2/images/prime.png" %}">
</div>
<input type="hidden" name="standardBountiesId"
value="{{bounty.standard_bounties_id}}">
<input type="hidden" name="bountyOwnerAddress"
value="{{bounty.bounty_owner_address}}">
<input type="hidden" name="valueInToken"
value="{{bounty.value_in_token}}">
<div class="col offset-md-1 col-md-10 d-flex align-items-center justify-content-center" id="primary_form">
<div class="d-flex justify-content-center flex-column mt-5" id="primary_subform">
<div class="w-100 text-center">
<h3>Increase Funding</h3>
<img src="{% static "v2/images/prime.png" %}">
</div>
{% include 'shared/bounty_actions_hidden_vars.html' %}
{% include 'shared/network_status.html' %}
<div class="w-100">
<label class="form__label" for=issueURL>Issue URL</label>
<input name='issueURL' id="issueURL" class="w-100 form__input" type="url" placeholder="https://github.com/user/repo/issues/n" value="{% if bounty %}{{bounty.github_url}}{%endif%}" disabled/>
</div>
<div class="w-100 mt-2">
<label class="form__label" for="amount">Amount</label>
<div class="form__flex-group">
<div class="form__amount-wrapper">
<input name='amount' id='amount' value='0.01' min="0.01" step="0.0001" class="form__input" type="number" placeholder="Amount" />
</div>
<div class="form__group-item font-body">
<div class="form__select2">
<select name='denomination' id='token' data-token-address='{{bounty.token_address}}' disabled></select>
</div>
</div>

<input type="hidden" name="standardBountiesId" value="{{bounty.standard_bounties_id}}">
<input type="hidden" name="bountyOwnerAddress" value="{{bounty.bounty_owner_address}}">
<input type="hidden" name="valueInToken" value="{{bounty.value_in_token}}">

<div class="col-lg-7 col-sm-12 my-5 pt-5" id="primary_form">
<div id="primary_subform">
<div class="bg-white rounded p-5">
<h1 class="text-center title">{% trans "Increase Bounty" %}</h1>
<p class="text-center font-bigger-1 text-black-60">Contribute funds to increase the reward for this bounty!</p>

{% include 'shared/bounty_actions_hidden_vars.html' %}
<div class="mt-4">
<label class="form__label mb-0" for=issueURL>Issue URL</label>
<p class="font-subheader">{{ bounty.title }}</p>
</div>
<small class="form__input-help form__input-help--dynamic" id="usd_amount"></small>
</div>
<div id="gas-section" class="mt-2">
{% include 'shared/wallet_estimate.html' %}
</div>
{% if FEE_PERCENTAGE != 0 %}
<div id="fee-section" class="mt-4">
<h5 class="font-subheader">{% trans "No Surprises" %}</h5>
<div class="row">
<div class="col-12 col-sm-9 mt-3 font-body">
<p>
{% blocktrans %}
Simply pay the bounty amount ( plus a standard
<span class="fee-percentage font-weight-bold">10</span><span class="font-weight-bold">%</span> Gitcoin platform fee ).
This covers our costs for finding quality contributors to join our platform so that you get the best work.
If your business requires additional assistance, please contact us <a href="mailto:[email protected]">[email protected]</a>
{% endblocktrans %}
</p>
<div>
<label class="form__label mb-0" for=issueURL>Issue URL</label>
<p class="font-subheader" id="issueURL">{{ bounty.github_url }}</p>
</div>
<div class="mt-2">
<div class="form__flex-group">
<div class="form__amount-wrapper">
<label class="form__label" for="amount">Amount</label>
<input name='amount' id='amount' value='0.01' min="0.01" step="0.0001" class="form__input" type="number" placeholder="Amount" />
</div>
<div class="col-12 col-sm-3 order-first order-sm-last mt-4 mt-sm-2 mt-md-0 mb-4 mb-sm-3">
<div class="fee-circle text-center">
<p class="font-title mb-0"><span id="fee-amount">0</span> <span id="fee-token">{{ bounty.token_name }}</span></p>
<p class="font-body font-weight-semibold">
(<span class="fee-percentage">10</span>%)
</p>
<div class="form__group-item font-body">
<label class="form__label" for="token">Token</label>
<div class="form__select2">
<select name='denomination' id='token' data-token-address='{{bounty.token_address}}' disabled></select>
</div>
</div>
</div>
<small class="form__input-help form__input-help--dynamic" id="usd_amount"></small>
</div>
{% endif %}
<div id="total-section" class="row mt-3 py-3">
<div class="col-sm-2 my-auto">
<h5 class="font-title-lg mb-0">{% trans "Total"%} </h5>
<div id="gas-section" class="py-4">
{% include 'shared/wallet_estimate.html' %}
</div>
<div class="col-sm-10 text-sm-right my-auto">
<p class="mb-1">{% trans "Payment Due = " %} <span id="summary-total-amount" class="font-weight-bold"></span></p>

<p class="font-caption mb-1">
( Increased Bounty <span id="summary-bounty-amount" class="font-weight-bold">0</span>
<span id="summary-bounty-token" class="font-weight-bold">{{ bounty.token_name }}</span> +

{% if FEE_PERCENTAGE == 0 %}
<span class="font-weight-bold">NO</span>
{% else %}
<span id="summary-fee-amount" class="font-weight-bold">0</span>
<span id="summary-fee-token" class="font-weight-bold">{{ bounty.token_name }}</span>
{% endif %}
Gitcoin Platform Fee )
</p>
<p class="font-caption mb-0">
You will have to approve
<span id="confirmation" class="font-weight-bold">
{% if FEE_PERCENTAGE == 0 %} 1 Metamask confirmation. {% else %} 2 Metamask confirmations.{% endif %}
</span>
</p>
{% if FEE_PERCENTAGE != 0 %}
<div id="fee-section" class="mt-4">
<h5 class="font-subheader">{% trans "No Surprises" %}</h5>
<div class="row">
<div class="col-12 col-sm-9 mt-3 font-body">
<p>
{% blocktrans %}
Simply pay the bounty amount ( plus a standard
<span class="fee-percentage font-weight-bold">10</span><span class="font-weight-bold">%</span> Gitcoin platform fee ).
This covers our costs for finding quality contributors to join our platform so that you get the best work.
If your business requires additional assistance, please contact us <a href="mailto:[email protected]">[email protected]</a>
{% endblocktrans %}
</p>
</div>
<div class="col-12 col-sm-3 order-first order-sm-last mt-4 mt-sm-2 mt-md-0 mb-4 mb-sm-3">
<div class="fee-circle text-center">
<p class="font-title mb-0"><span id="fee-amount">0</span> <span id="fee-token">{{ bounty.token_name }}</span></p>
<p class="font-body font-weight-semibold">
(<span class="fee-percentage">10</span>%)
</p>
</div>
</div>
</div>
</div>
{% endif %}

<div class="w-100 terms_container mb-3" style="padding-top:5px;">
<div class="form__checkbox">
<input name='terms' id='terms' type="checkbox" value=1 required />
<label class="form__label" for=terms>I have read, understand, and agree to, the <a href="{% url "terms" %}" target=new>Terms of Service</a>.</label>
</div>
</div>
</div>
<div class="w-100 terms_container mb-3" style="padding-top:5px;">
<div class="form__checkbox">
<input name='terms' id='terms' type="checkbox" value=1 required />
<label class="form__label" for=terms>I have read, understand, and agree to, the <a href="{% url "terms" %}" target=new>Terms of Service</a>.</label>

<div class="bg-white my-3 px-5 rounded">
<div id="total-section" class="row mt-3 py-3">
<div class="col-sm-2 my-auto">
<h5 class="text-uppercase h3 font-weight-bold mb-0">{% trans "Total"%}</h5>
</div>
<div class="col-sm-10 my-auto">
<p class="mb-1 text-uppercase text-black-50 font-body">{% trans "Payment Due" %}</p>
<span id="summary-total-amount" class="h2 text-darkblue font-weight-bold my-3 d-block"></span>
<p class="font-caption text-black-50 mb-1">
( Increased Bounty Amount <span id="summary-bounty-amount" class="font-weight-bold">0</span>
<span id="summary-bounty-token" class="font-weight-bold">{{ bounty.token_name }}</span> +

{% if FEE_PERCENTAGE == 0 %}
+ <span class="font-weight-bold">No Fees</span>
{% else %}
+
<span id="summary-fee-amount" class="font-weight-bold">0</span>
<span id="summary-fee-token" class="font-weight-bold">{{ bounty.token_name }}</span>
{% endif %}
Gitcoin Platform Fee )
</p>
<p class="font-caption mb-0">
You will have to approve
<span id="confirmation" class="font-weight-bold">
{% if FEE_PERCENTAGE == 0 %} 1 Metamask confirmation. {% else %} 2 Metamask confirmations.{% endif %}
</span>
</p>
</div>
</div>
</div>
<button class="button button--primary w-100" type="submit" id="increaseFunding">Increase Funding</button>
<div class="mt-3 text-center">
<a id="increase_funding_explainer" class="font-caption text-center" target="_blank" rel="noopener noreferrer" href="https://github.com/gitcoinco/web#high-level-flows">
Your transaction is secured by the audited StandardBounties contract on the Ethereum blockchain. </br>
Learn more here.
</a>

<div class="pb-5 text-center">
<button class="font-subheader btn btn-gc-blue btn-lg mb-3 w-25 btn-lg-padding" type="submit" id="increaseFunding">Increase Funding</button>
<p class="font-caption blue">
Your transaction is secured by the audited StandardBounties contract on the Ethereum blockchain.
<a class="text-reset underline" target="_blank" rel="noopener noreferrer" href="https://github.com/gitcoinco/web#high-level-flows">Learn more here.</a>
</p>
</div>
</div>
</div>
Expand All @@ -171,6 +176,9 @@ <h5 class="font-title-lg mb-0">{% trans "Total"%} </h5>
<script>
document.is_funder_github_user_same = {{ is_funder }};
document.FEE_PERCENTAGE = {{ FEE_PERCENTAGE }};
{% if expired_coupon %}
_alert({ message: 'This coupon has expired.' }, 'error');
{% endif %}
</script>

<script src="{% static "v2/js/pages/wallet_estimate.js" %}"></script>
Expand Down
19 changes: 10 additions & 9 deletions app/dashboard/templates/shared/success_container.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
{% endcomment %}
{% load i18n static %}
<div class="row" id="success_container" style="display: none; min-height: 500px;">
<div class="col offset-md-1 col-md-10 d-flex align-items-center justify-content-center">
<div class="d-flex justify-content-center flex-column mt-5">
<h3>{% trans "Transaction Sent" %}</h3>
{% include 'svgs/success.svg' %}
<a class="button button--primary mt-3 text-center" href="{{bounty.url}}">
{% trans "Back to Bounty" %}
</a>
<div class="col text-center">
<div class="mt-5">
<h3 class="font-title text-center">{% trans "Transaction Sent" %}</h3>
<img class="my-4" src="{% static "v2/images/modals/persona-choose.svg" %}" height="180">
<p>
<a class="mt-4 font-body btn btn-gc-blue btn-lg text-center" href="{{bounty.url}}">
{% trans "Back to Bounty" %}
</a>
</p>
</div>
</div>
</div>

</div>
9 changes: 9 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,15 @@ def increase_bounty(request):
params['is_funder'] = json.dumps(is_funder)
params['FEE_PERCENTAGE'] = request.user.profile.fee_percentage if request.user.is_authenticated else 10

coupon_code = request.GET.get('coupon', False)
if coupon_code:
coupon = Coupon.objects.get(code=coupon_code)
if coupon.expiry_date > datetime.now().date():
params['FEE_PERCENTAGE'] = coupon.fee_percentage
params['coupon_code'] = coupon.code
else:
params['expired_coupon'] = True

return TemplateResponse(request, 'bounty/increase.html', params)


Expand Down

0 comments on commit cc2d4f2

Please sign in to comment.