Skip to content

Commit 0fb90bf

Browse files
renzonrenzon
authored andcommitted
Removed Meteoric Launch page, Moved membership code from payments to launch app
related to #2411
1 parent 2f4c535 commit 0fb90bf

File tree

13 files changed

+61
-213
lines changed

13 files changed

+61
-213
lines changed

contrib/env-sample

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CHAVE_PAGARME_API_PRIVADA=
1414

1515
# Control subscriptions ads and payment.
1616
SUBSCRIPTIONS_OPEN=False
17-
METEORIC_LAUNCH_OPEN=False
1817
PAGSEGURO_PAYMENT_PLAN=YOUR PAYMENT PLAN ON pagseguro
1918

2019
# Amazon S3 configuration

pythonpro/payments/templates/payments/member_landing_page_subscription_closed.html renamed to pythonpro/launch/templates/launch/member_landing_page_subscription_closed.html

File renamed without changes.

pythonpro/payments/templates/payments/member_landing_page_subscription_open.html renamed to pythonpro/launch/templates/launch/member_landing_page_subscription_open.html

File renamed without changes.

pythonpro/payments/templates/payments/meteoric_landing_page_open.html renamed to pythonpro/launch/templates/launch/meteoric_landing_page_open.html

File renamed without changes.

pythonpro/launch/tests/__init__.py

Whitespace-only changes.

pythonpro/launch/views.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
from django.conf import settings
44
from django.shortcuts import redirect, render
5+
from django.utils.http import urlencode
56
from django.views.static import serve
67
from django.urls import reverse
78

89
from pythonpro.absolute_uri import build_absolute_uri
10+
from pythonpro.cohorts import facade as cohorts_facade
911
from pythonpro.cohorts.facade import find_most_recent_cohort
10-
from pythonpro.domain import user_facade
12+
from pythonpro.domain import user_facade, membership_domain
1113
from pythonpro.launch.forms import LeadForm
1214
from pythonpro.email_marketing import facade as email_marketing_facade
1315
from pythonpro.launch.facade import (
@@ -157,3 +159,58 @@ def onesignal_sdk_updater_worker(request):
157159
'js/spp/OneSignalSDUpdaterKWorker.js',
158160
document_root=os.path.join(settings.BASE_DIR, 'pythonpro', 'core', 'static')
159161
)
162+
163+
164+
def member_landing_page(request):
165+
template_open_launch = 'payments/meteoric_landing_page_open.html'
166+
template_closed_launch = 'payments/member_landing_page_subscription_closed.html'
167+
is_launch_open = settings.SUBSCRIPTIONS_OPEN or request.GET.get('debug')
168+
return _render_launch_page(is_launch_open, request, template_closed_launch, template_open_launch,
169+
'member_landing_page')
170+
171+
172+
173+
174+
def _render_launch_page(is_launch_open, request, template_closed_launch, template_open_launch, redirect_path_name: str):
175+
user = request.user
176+
if user.is_authenticated:
177+
user_facade.visit_member_landing_page(request.user, source=request.GET.get('utm_source', default='unknown'))
178+
notification_url = reverse('payments:membership_notification', kwargs={'user_id': user.id})
179+
else:
180+
notification_url = reverse('payments:membership_anonymous_notification')
181+
if is_launch_open:
182+
template = template_open_launch
183+
discount = membership_domain.calculate_discount(user)
184+
discount_float = discount / 100
185+
186+
price = membership_domain.calculate_membership_price(user)
187+
price_float = price / 100
188+
full_price_float = price_float + discount_float
189+
price_installment = (price // 10) / 100
190+
full_price_installment = full_price_float // 10
191+
login_url = reverse('two_factor:login')
192+
redirect_path = reverse(redirect_path_name)
193+
qs = urlencode({'utm_source': request.GET.get('utm_source', 'unknown')})
194+
redirect_url = f'{redirect_path}?{qs}'
195+
qs = urlencode({'next': redirect_url})
196+
login_url = f'{login_url}?{qs}'
197+
return render(
198+
request,
199+
template,
200+
{
201+
'PAGARME_CRYPTO_KEY': settings.PAGARME_CRYPTO_KEY,
202+
'price': price,
203+
'price_float': price_float,
204+
'price_installment': price_installment,
205+
'notification_url': request.build_absolute_uri(notification_url),
206+
'cohort': cohorts_facade.find_most_recent_cohort(),
207+
'has_discount': discount_float > 0,
208+
'discount_float': discount_float,
209+
'full_price_installment': full_price_installment,
210+
'full_price_float': full_price_float,
211+
'login_url': login_url,
212+
}
213+
)
214+
else:
215+
template = template_closed_launch
216+
return render(request, template, {})

pythonpro/payments/templates/payments/meteoric_landing_page_closed.html

Lines changed: 0 additions & 21 deletions
This file was deleted.

pythonpro/payments/tests/test_meteoric_launch_closed.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

pythonpro/payments/tests/test_metoric_launch_open.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

pythonpro/payments/urls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
path('curso-completo/obrigado/', views.membership_thanks, name='membership_thanks'),
1414
path('membro/captura/', views.member_capture, name='member_capture'),
1515
path('membro/boleto/', views.membership_boleto, name='membership_boleto'),
16-
path('pargarme/notificacao/<int:user_id>', views.pagarme_notification, name='pagarme_notification'),
17-
path('membership/notification/<int:user_id>', views.membership_notification, name='membership_notification'),
1816

1917
# unused pages
2018
path(

0 commit comments

Comments
 (0)