Skip to content

Commit 11669c2

Browse files
moacirmodarenzon
authored andcommitted
changing python birds to stop to register user in django and redirecting to new thank you page.
1 parent b457813 commit 11669c2

3 files changed

Lines changed: 61 additions & 7 deletions

File tree

pythonpro/core/tests/test_lead_landing_page.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,6 @@ def test_should_has_a_normal_version(resp):
224224
dj_assert_template_used(resp, 'core/lead_landing_page.html')
225225

226226

227-
def test_should_has_a_lite_version(client):
228-
resp = client.get(reverse('core:lead_landing_lite'))
229-
dj_assert_template_used(resp, 'core/lead_landing_lite_page.html')
230-
231-
232227
def test_should_use_lead_form_with_no_offer(client):
233228
resp = client.get(reverse('core:lead_landing_with_no_offer'))
234229
dj_assert_not_contains(resp, reverse('core:lead_form') + '"')
@@ -320,3 +315,35 @@ def resp_with_utm(client, qs_with_utms):
320315

321316
def test_should_send_utms_to_form_action(qs_with_utms, resp_with_utm):
322317
dj_assert_contains(resp_with_utm, qs_with_utms)
318+
319+
320+
def test_lead_creation_with_no_registration_status_code(client):
321+
resp = client.get(reverse('core:lead_landing_with_no_registration'))
322+
assert 200 == resp.status_code
323+
324+
325+
def test_lead_creation_with_no_registration(create_lead_mock, fake, client):
326+
name = fake.name()
327+
email = fake.email()
328+
url = reverse('core:lead_landing_with_no_registration')
329+
url = url + '?utm_source=facebook&utm_medium=trafego-organico&utm_campaign=L12'
330+
331+
client.post(
332+
url,
333+
data={
334+
'first_name': name,
335+
'email': email,
336+
'phone': '(11)966922655',
337+
},
338+
secure=True
339+
)
340+
341+
create_lead_mock.assert_called_once_with(
342+
name,
343+
email,
344+
'utm_source=facebook',
345+
'utm_medium=trafego-organico',
346+
'utm_campaign=L12',
347+
phone='11966922655',
348+
utm_source='facebook',
349+
)

pythonpro/core/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
path('tech-talks', views.teck_talks, name='tech_talks'),
1414
path('linktree', views.linktree, name='linktree'),
1515
path('podcast', views.podcast, name='podcast'),
16-
path('curso-de-python-gratis', views.lead_landing, name='lead_landing'),
17-
path('curso-de-python-gratis-lite', views.lead_landing_lite, name='lead_landing_lite'),
16+
path('curso-de-python-gratis', views.lead_landing_with_no_registration, name='lead_landing_with_no_registration'),
17+
path('curso-de-python-gratis-lite', views.lead_landing, name='lead_landing'),
1818
path('curso-de-python-gratis-no', views.lead_landing_with_no_offer, name='lead_landing_with_no_offer'),
1919
path('cadastro-python-birds', views.lead_form, name='lead_form'),
2020
path('cadastro-python-birds-no', views.lead_form_with_no_offer, name='lead_form_with_no_offer'),

pythonpro/core/views.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from rolepermissions.checkers import has_role
1212

1313
from pythonpro.core import facade as core_facade
14+
from pythonpro.email_marketing import facade as email_marketing_facade
1415
from pythonpro.core.forms import LeadForm, UserEmailForm, UserSignupForm, PythonProResetForm
1516
from pythonpro.core.models import User
1617
from pythonpro.domain import user_domain
@@ -212,3 +213,29 @@ class _PythonProResetView(PasswordResetView):
212213

213214

214215
password_reset = _PythonProResetView.as_view()
216+
217+
218+
def lead_landing_with_no_registration(request, *args, **kwargs):
219+
if request.method == 'GET':
220+
form_action = reverse('core:lead_landing_with_no_registration')
221+
form_action = f"{form_action}?{request.GET.urlencode(safe='&')}"
222+
return render(request, 'core/lead_landing_page.html', context={'form': LeadForm(), 'form_action': form_action})
223+
224+
source = request.GET.get('utm_source', default='unknown')
225+
first_name = request.POST.get('first_name')
226+
email = request.POST.get('email')
227+
phone = request.POST.get('phone')
228+
tags = []
229+
for key, value in request.GET.items():
230+
if key.startswith('utm_'):
231+
tags.append(f"{key}={value}")
232+
233+
phone = phone.replace('(', '')
234+
phone = phone.replace(')', '')
235+
phone = phone.replace(' ', '')
236+
237+
email_marketing_facade.create_or_update_lead.delay(
238+
first_name, email, phone=phone, *tags, utm_source=source
239+
)
240+
241+
return redirect('https://pythonpro.com.br/python-birds-obrigado/')

0 commit comments

Comments
 (0)