Skip to content

Commit

Permalink
virality on the post grant fund modal
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Sep 5, 2019
1 parent 61b8037 commit 8121c36
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 29 deletions.
28 changes: 4 additions & 24 deletions app/grants/templates/grants/fund.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,30 +324,10 @@ <h5 class="form__label">{% trans "Gas Settings" %}</h5>
</div>

</div>
<div class="modal" id="tweetModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" style="margin-top: 10px;">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="javascript:$('#tweetModal').remove();">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body mt-4 mx-5 font-body">
<div class="row mb-3 justify-content-center">
<img class="icon w-75 h-75" src="{% static "v2/images/grants/torchbearer.svg" %}" />
</div>
<h5>Thanks for Contributing!</h5>
<span>{% trans "Tell your network about this Gitcoin Grant. If they fund a grant, the grant owner will get even more Matching Funds!" %}</span>
</div>
<div class="row my-4 justify-content-center">
<a class="button button--primary" role="button" href="https://twitter.com/intent/tweet?text=I just funded this grant on @gitcoin => https://{{ request.META.HTTP_HOST }}{% url 'grants:details' grant.id grant.slug %}"
target="_blank" rel="noopener noreferrer" OnClick="ga('send', 'event', 'Tweet Button', 'click', 'Grant Funder')">
{% trans "Tweet About it!" %}
</a>
</div>
</div>
</div>
</div>

{% include 'shared/grant_thanks_modal.html' %}


{% include 'shared/bottom_notification.html' %}
{% include 'shared/analytics.html' %}
{% include 'shared/footer_scripts.html' %}
Expand Down
15 changes: 11 additions & 4 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from gas.utils import conf_time_spread, eth_usd_conv_rate, gas_advisories, recommend_min_gas_price_to_confirm_in_time
from grants.forms import MilestoneForm
from grants.models import Contribution, Grant, MatchPledge, Milestone, PhantomFunding, Subscription, Update
from kudos.models import BulkTransferCoupon
from marketing.mails import (
grant_cancellation, new_grant, new_supporter, subscription_terminated, support_cancellation,
thank_you_for_supporting,
Expand Down Expand Up @@ -502,6 +503,7 @@ def grant_fund(request, grant_id, grant_slug):
else:
record_subscription_activity_helper('new_grant_subscription', subscription, profile)

# TODO - how do we attach the tweet modal WITH BULK TRANSFER COUPON next pageload??
messages.info(
request,
_('Your subscription has been created. It will bill within the next 5 minutes or so. Thank you for supporting Open Source !')
Expand Down Expand Up @@ -535,25 +537,29 @@ def grant_fund(request, grant_id, grant_slug):

# handle phantom funding
active_tab = 'normal'
fund_reward = None
round_number = 3
can_phantom_fund = request.user.is_authenticated and request.user.groups.filter(name='phantom_funders').exists()
phantom_funds = PhantomFunding.objects.filter(profile=request.user.profile, grant=grant, round_number=round_number)
is_phantom_funding_this_grant = request.user.is_authenticated and phantom_funds.exists()
is_phantom_funding_this_grant = can_phantom_fund and request.user.is_authenticated and phantom_funds.exists()
show_tweet_modal = False
if can_phantom_fund:
active_tab = 'phantom'
if can_phantom_fund and request.GET.get('toggle_phantom_fund'):
if is_phantom_funding_this_grant:
msg = "You are now signaling for this grant."
msg = "You are no longer signaling for this grant."
phantom_funds.delete()
show_tweet_modal = True
else:
msg = "You are no longer signaling for this grant."
msg = "You are now signaling for this grant."
show_tweet_modal = True
name_search = 'grants_round_3_contributor_' if not settings.DEBUG else 'pogs_eth'
fund_reward = BulkTransferCoupon.objects.filter(token__name__contains=name_search).order_by('?').first()
PhantomFunding.objects.create(grant=grant, profile=request.user.profile, round_number=round_number)
messages.info(
request,
msg
)
is_phantom_funding_this_grant = not is_phantom_funding_this_grant



Expand All @@ -578,6 +584,7 @@ def grant_fund(request, grant_id, grant_slug):
'can_phantom_fund': can_phantom_fund,
'is_phantom_funding_this_grant': is_phantom_funding_this_grant,
'active_tab': active_tab,
'fund_reward': fund_reward,
}
return TemplateResponse(request, 'grants/fund.html', params)

Expand Down
3 changes: 2 additions & 1 deletion app/kudos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ def receive_bulk(request, secret):

title = f"Redeem {coupon.token.humanized_name} Kudos from @{coupon.sender_profile.handle}"
desc = f"This Kudos has been AirDropped to you. About this Kudos: {coupon.token.description}"
tweet_text = f"I just got a {coupon.token.humanized_name} Kudos on @gitcoin. " if not request.GET.get('tweet', None) else request.GET.get('tweet')
params = {
'title': title,
'card_title': title,
Expand All @@ -739,6 +740,6 @@ def receive_bulk(request, secret):
'class': _class,
'is_authed': request.user.is_authenticated,
'kudos_transfer': kudos_transfer,
'tweet_text': urllib.parse.quote_plus(f"I just got a {coupon.token.humanized_name} Kudos on @gitcoin. ")
'tweet_text': urllib.parse.quote_plus(tweet_text)
}
return TemplateResponse(request, 'transaction/receive_bulk.html', params)
54 changes: 54 additions & 0 deletions app/retail/templates/shared/grant_thanks_modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% comment %}
Copyright (C) 2019 Gitcoin Core

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

{% endcomment %}
{% load i18n static %}
<div class="modal" id="tweetModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" style="margin-top: 10px; background-color: #eee;">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="javascript:$('#tweetModal').remove();">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body mt-4 mx-5 font-body">
<div class="row mb-3 justify-content-center">
{% if not fund_reward %}
<img class="icon w-75 h-75" src="{% static "v2/images/grants/torchbearer.svg" %}" />
<h5>Thanks for Contributing!</h5>
<span>{% trans "Tell your network about this Gitcoin Grant. If they fund a grant, the grant owner will get even more Matching Funds!" %}</span>
{% else %}
<img class="icon w-75 h-75" src="{{fund_reward.token.img_url}}" />
<h5>Thanks for Contributing! You Earned a Kudos</h5>
<span>Have a <strong>{{fund_reward.token.ui_name}}</strong> Kudos on us. When you click 'redeem kudos' your kudos will be transfered to your Ethereum wallet. </span>
{% endif %}
</div>
</div>
<div class="row my-4 justify-content-center">
{% if fund_reward %}
<a class="button button--primary" role="button" href="{{fund_reward.url}}?tweet=I just funded a grant on @gitcoin (https://{{ request.META.HTTP_HOST }}{% url 'grants:details' grant.id grant.slug %}) and got this sweet Kudos! => "
target="_blank" rel="noopener noreferrer" >
{% trans "Redeem Kudos" %} 🌈
</a> |
{% endif %}
<a class="button button--primary" role="button" href="https://twitter.com/intent/tweet?text=I just funded this grant on @gitcoin => https://{{ request.META.HTTP_HOST }}{% url 'grants:details' grant.id grant.slug %}"
target="_blank" rel="noopener noreferrer" OnClick="ga('send', 'event', 'Tweet Button', 'click', 'Grant Funder')">
{% trans "Tweet About this Grant" %} 🐦
</a>
</div>
</div>
</div>
</div>

0 comments on commit 8121c36

Please sign in to comment.