From 8121c360efa2cff882eef4f75e09159338337974 Mon Sep 17 00:00:00 2001 From: Owocki Date: Wed, 4 Sep 2019 19:40:38 -0600 Subject: [PATCH] virality on the post grant fund modal --- app/grants/templates/grants/fund.html | 28 ++-------- app/grants/views.py | 15 ++++-- app/kudos/views.py | 3 +- .../templates/shared/grant_thanks_modal.html | 54 +++++++++++++++++++ 4 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 app/retail/templates/shared/grant_thanks_modal.html diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index d94befad8a8..a40bce7c00f 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -324,30 +324,10 @@
{% trans "Gas Settings" %}
- + + {% include 'shared/grant_thanks_modal.html' %} + + {% include 'shared/bottom_notification.html' %} {% include 'shared/analytics.html' %} {% include 'shared/footer_scripts.html' %} diff --git a/app/grants/views.py b/app/grants/views.py index 3f7bd5b6a63..e120bd9e053 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -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, @@ -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 !') @@ -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 @@ -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) diff --git a/app/kudos/views.py b/app/kudos/views.py index dd8e5f72348..279633d7c4b 100644 --- a/app/kudos/views.py +++ b/app/kudos/views.py @@ -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, @@ -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) diff --git a/app/retail/templates/shared/grant_thanks_modal.html b/app/retail/templates/shared/grant_thanks_modal.html new file mode 100644 index 00000000000..ba44aa7664b --- /dev/null +++ b/app/retail/templates/shared/grant_thanks_modal.html @@ -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 . + +{% endcomment %} +{% load i18n static %} +