Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pythonpro/modules/tests/test_topics_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def resp_lead_accesing_client_content(client_with_lead, topic_client, django_use


def test_lead_hitting_client_landing_page(resp_lead_accesing_client_content):
dj_assert_template_used(resp_lead_accesing_client_content, 'topics/content_client_landing_page.html')
assert resp_lead_accesing_client_content.status_code == 302
assert resp_lead_accesing_client_content.url == reverse('payments:client_landing_page')


@pytest.fixture
Expand Down
6 changes: 3 additions & 3 deletions pythonpro/modules/topics_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@


def content_landing_page(request, content: Content):
if is_client_content(content):
tag_as(request.user.email, 'potencial-client')
return redirect(reverse('payments:client_landing_page'), permanent=False)
template = 'topics/content_member_landing_page.html'
tag = 'potencial-member'
if is_client_content(content):
template = 'topics/content_client_landing_page.html'
tag = 'potencial-client'

tag_as(request.user.email, tag)
return render(request, template, {
Expand Down
11 changes: 11 additions & 0 deletions pythonpro/payments/tests/test_landing_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest
from django.urls import reverse


@pytest.fixture
def client_lp_resp(client_with_lead):
return client_with_lead.get(reverse('payments:client_landing_page'), secure=True)


def test_non_logged_status_code(client_lp_resp):
assert client_lp_resp.status_code == 200
1 change: 1 addition & 0 deletions pythonpro/payments/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
path('pytools/obrigado/', views.pytools_thanks, name='pytools_thanks'),
path('pytools/captura/', views.pytools_capture, name='pytools_capture'),
path('pytools/boleto/', views.pytools_boleto, name='pytools_boleto'),
path('curso-de-python-intermediario', views.client_landing_page, name='client_landing_page'),
path('pargarme/notificacao/<int:user_id>', views.pagarme_notification, name='pagarme_notification'),
]
19 changes: 17 additions & 2 deletions pythonpro/payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from pythonpro.mailchimp import facade as mailchimp_facade
from pythonpro.payments import facade as payment_facade
from pythonpro.payments.facade import PYTOOLS_PRICE


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


@login_required
def client_landing_page(request):
notification_url = reverse('payments:pagarme_notification', kwargs={'user_id': request.user.id})
return render(
request,
'payments/client_landing_page.html', {
'PAGARME_CRYPTO_KEY': settings.PAGARME_CRYPTO_KEY,
'price': PYTOOLS_PRICE,
'notification_url': request.build_absolute_uri(
notification_url
)
})


def pagarme_notification(request, user_id: int):
if request.method != 'POST':
return HttpResponseNotAllowed(['POST'])
return HttpResponseNotAllowed([request.method])

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