Skip to content

Commit b8e2a7a

Browse files
renzonrenzon
authored andcommitted
Created client landing page path
close #1174
1 parent 5322951 commit b8e2a7a

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

pythonpro/modules/tests/test_topics_view.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ def resp_lead_accesing_client_content(client_with_lead, topic_client, django_use
205205

206206

207207
def test_lead_hitting_client_landing_page(resp_lead_accesing_client_content):
208-
dj_assert_template_used(resp_lead_accesing_client_content, 'topics/content_client_landing_page.html')
208+
assert resp_lead_accesing_client_content.status_code == 302
209+
assert resp_lead_accesing_client_content.url == reverse('payments:client_landing_page')
209210

210211

211212
@pytest.fixture

pythonpro/modules/topics_views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313

1414
def content_landing_page(request, content: Content):
15+
if is_client_content(content):
16+
tag_as(request.user.email, 'potencial-client')
17+
return redirect(reverse('payments:client_landing_page'), permanent=False)
1518
template = 'topics/content_member_landing_page.html'
1619
tag = 'potencial-member'
17-
if is_client_content(content):
18-
template = 'topics/content_client_landing_page.html'
19-
tag = 'potencial-client'
2020

2121
tag_as(request.user.email, tag)
2222
return render(request, template, {

pythonpro/modules/templates/topics/content_client_landing_page.html renamed to pythonpro/payments/templates/payments/client_landing_page.html

File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
from django.urls import reverse
3+
4+
5+
@pytest.fixture
6+
def client_lp_resp(client_with_lead):
7+
return client_with_lead.get(reverse('payments:client_landing_page'), secure=True)
8+
9+
10+
def test_non_logged_status_code(client_lp_resp):
11+
assert client_lp_resp.status_code == 200

pythonpro/payments/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
path('pytools/obrigado/', views.pytools_thanks, name='pytools_thanks'),
1010
path('pytools/captura/', views.pytools_capture, name='pytools_capture'),
1111
path('pytools/boleto/', views.pytools_boleto, name='pytools_boleto'),
12+
path('curso-de-python-intermediario', views.client_landing_page, name='client_landing_page'),
1213
path('pargarme/notificacao/<int:user_id>', views.pagarme_notification, name='pagarme_notification'),
1314
]

pythonpro/payments/views.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from pythonpro.mailchimp import facade as mailchimp_facade
1515
from pythonpro.payments import facade as payment_facade
16+
from pythonpro.payments.facade import PYTOOLS_PRICE
1617

1718

1819
def options(request):
@@ -61,9 +62,23 @@ def _extract_boleto_params(dct):
6162
return {k: dct[k] for k in ['boleto_barcode', 'boleto_url']}
6263

6364

65+
@login_required
66+
def client_landing_page(request):
67+
notification_url = reverse('payments:pagarme_notification', kwargs={'user_id': request.user.id})
68+
return render(
69+
request,
70+
'payments/client_landing_page.html', {
71+
'PAGARME_CRYPTO_KEY': settings.PAGARME_CRYPTO_KEY,
72+
'price': PYTOOLS_PRICE,
73+
'notification_url': request.build_absolute_uri(
74+
notification_url
75+
)
76+
})
77+
78+
6479
def pagarme_notification(request, user_id: int):
6580
if request.method != 'POST':
66-
return HttpResponseNotAllowed(['POST'])
81+
return HttpResponseNotAllowed([request.method])
6782

6883
paymento_ok = payment_facade.confirm_boleto_payment(
6984
user_id, request.POST, request.body.decode('utf8'), request.headers['X-Hub-Signature'])
@@ -78,7 +93,7 @@ def pagarme_notification(request, user_id: int):
7893
}
7994
)
8095
send_mail(
81-
'Inscrição no curso Pytool realizad, confira o link com detalhes!',
96+
'Inscrição no curso Pytool realizada! Confira o link com detalhes.',
8297
msg,
8398
settings.DEFAULT_FROM_EMAIL,
8499
[user.email]

0 commit comments

Comments
 (0)