Skip to content

Commit ef21142

Browse files
committed
creating new lead landing page that not redirects to OTO
1 parent 5147aaf commit ef21142

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

pythonpro/core/tests/test_lead_landing_page.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,19 @@ def test_should_redirect_to_OTO_page(resp_lead_creation):
178178

179179
def test_should_has_a_lite_version(client):
180180
assert client.get(reverse('core:lead_landing_lite'), secure=True)
181+
182+
183+
@pytest.fixture
184+
def resp_lead_creation_without_OTO(client, db, fake: Faker, create_lead_mock, email):
185+
return client.post(
186+
reverse('core:lead_landing_without_OTO'),
187+
data={
188+
'first_name': fake.name(),
189+
'email': email,
190+
},
191+
secure=True
192+
)
193+
194+
195+
def test_should_has_a_version_that_not_redirect_to_OTO_page(resp_lead_creation_without_OTO):
196+
assert resp_lead_creation_without_OTO['Location'] == reverse('core:thanks')

pythonpro/core/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
path('podcast', views.podcast, name='podcast'),
1313
path('curso-de-python-gratis', views.lead_landing, name='lead_landing'),
1414
path('curso-de-python-gratis-lite', views.lead_landing_lite, name='lead_landing_lite'),
15+
path('curso-de-python-gratis-no-oto', views.lead_form_without_OTO, name='lead_landing_without_OTO'),
1516
path('cadastro-python-birds', views.lead_form, name='lead_form'),
1617
path('definir-senha', views.lead_change_password, name='lead_change_password'),
1718
path('obrigado', views.thanks, name='thanks'),

pythonpro/core/views.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,31 @@ def programmer_week_ty(request):
148148
return render(request, 'core/lead_landing_page.html', context={'form': UserSignupForm()})
149149

150150

151-
def lead_form(request):
151+
def _lead_form(request, redirect_to_OTO=True, *args, **kwargs):
152152
if request.method == 'GET':
153153
form = UserSignupForm()
154154
return render(request, 'core/lead_form_errors.html', context={'form': form})
155+
155156
source = request.GET.get('utm_source', default='unknown')
156157
first_name = request.POST.get('first_name')
157158
email = request.POST.get('email')
159+
158160
try:
159161
user = user_facade.register_lead(first_name, email, source)
160162
except user_facade.UserCreationException as e:
161163
return render(request, 'core/lead_form_errors.html', context={'form': e.form}, status=400)
164+
162165
login(request, user)
163-
return redirect(reverse('payments:client_landing_page_oto'))
166+
167+
if redirect_to_OTO:
168+
return redirect(reverse('payments:client_landing_page_oto'))
169+
else:
170+
return redirect(reverse('core:thanks'))
171+
172+
173+
def lead_form(request):
174+
return _lead_form(request)
175+
176+
177+
def lead_form_without_OTO(request):
178+
return _lead_form(request, redirect_to_OTO=False)

0 commit comments

Comments
 (0)