Skip to content

Commit 49c159b

Browse files
renzonrenzon
authored andcommitted
Created waiting cohort list landing page
close #1207
1 parent d0b8dfd commit 49c159b

File tree

20 files changed

+243
-132
lines changed

20 files changed

+243
-132
lines changed

pythonpro/cohorts/templates/cohorts/live_class_landing_page.html

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

pythonpro/cohorts/templates/cohorts/webinar_landing_page.html

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

pythonpro/cohorts/tests/test_live_class_detail.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from model_mommy import mommy
66

77
from pythonpro.cohorts.models import Cohort, LiveClass
8-
from pythonpro.django_assertions import dj_assert_contains, dj_assert_template_used
8+
from pythonpro.django_assertions import dj_assert_contains
99

1010

1111
@pytest.fixture
@@ -45,24 +45,22 @@ def test_cohort_title(cohort, resp):
4545

4646
@pytest.fixture
4747
def resp_client(client_with_client, live_class: LiveClass, mocker, logged_user):
48-
tag_as = mocker.patch('pythonpro.cohorts.views.tag_as')
49-
yield client_with_client.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)
50-
tag_as.assert_called_once_with(logged_user.email, 'potencial-member')
48+
return client_with_client.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)
5149

5250

5351
def test_live_class_landing_for_client(cohort, resp_client):
54-
dj_assert_template_used(resp_client, 'cohorts/live_class_landing_page.html')
52+
assert resp_client.status_code == 302
53+
assert resp_client.url == reverse('payments:member_landing_page')
5554

5655

5756
@pytest.fixture
5857
def resp_lead(client_with_lead, live_class: LiveClass, mocker, logged_user):
59-
tag_as = mocker.patch('pythonpro.cohorts.views.tag_as')
60-
yield client_with_lead.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)
61-
tag_as.assert_called_once_with(logged_user.email, 'potencial-member')
58+
return client_with_lead.get(reverse('cohorts:live_class', kwargs={'pk': live_class.id}), secure=True)
6259

6360

6461
def test_live_class_landing_for_lead(cohort, resp_lead):
65-
dj_assert_template_used(resp_lead, 'cohorts/live_class_landing_page.html')
62+
assert resp_lead.status_code == 302
63+
assert resp_lead.url == reverse('payments:member_landing_page')
6664

6765

6866
def test_cohort_url(cohort: Cohort, resp):

pythonpro/cohorts/tests/test_webinar_detail.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from pythonpro.cohorts.models import Webinar
77
from pythonpro.cohorts.tests.conftest import img_path
8-
from pythonpro.django_assertions import dj_assert_contains, dj_assert_template_used
8+
from pythonpro.django_assertions import dj_assert_contains
99

1010

1111
@pytest.fixture
@@ -36,21 +36,19 @@ def test_basic_contents(resp, webinar, property_name):
3636

3737
@pytest.fixture
3838
def resp_client(client_with_client, webinar: Webinar, mocker, logged_user):
39-
tag_as = mocker.patch('pythonpro.cohorts.views.tag_as')
40-
yield client_with_client.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)
41-
tag_as.assert_called_once_with(logged_user.email, 'potencial-member')
39+
return client_with_client.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)
4240

4341

4442
def test_webinar_landing_for_client(cohort, resp_client):
45-
dj_assert_template_used(resp_client, 'cohorts/webinar_landing_page.html')
43+
assert resp_client.status_code == 302
44+
assert resp_client.url == reverse('payments:member_landing_page')
4645

4746

4847
@pytest.fixture
4948
def resp_lead(client_with_lead, webinar: Webinar, mocker, logged_user):
50-
tag_as = mocker.patch('pythonpro.cohorts.views.tag_as')
51-
yield client_with_lead.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)
52-
tag_as.assert_called_once_with(logged_user.email, 'potencial-member')
49+
return client_with_lead.get(reverse('cohorts:webinar', kwargs={'slug': webinar.slug}), secure=True)
5350

5451

5552
def test_webinar_landing_for_lead(cohort, resp_lead):
56-
dj_assert_template_used(resp_lead, 'cohorts/webinar_landing_page.html')
53+
assert resp_lead.status_code == 302
54+
assert resp_lead.url == reverse('payments:member_landing_page')

pythonpro/cohorts/views.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from django.contrib.auth.decorators import login_required
2-
from django.shortcuts import render
2+
from django.shortcuts import redirect, render
3+
from django.urls import reverse
34
from rolepermissions.checkers import has_permission
45

56
from pythonpro.cohorts import facade
67
from pythonpro.core.roles import access_cohorts
7-
from pythonpro.mailchimp.facade import tag_as
88

99

1010
@login_required
@@ -20,14 +20,12 @@ def webinars(request):
2020
@login_required
2121
def webinar(request, slug):
2222
if not has_permission(request.user, access_cohorts):
23-
tag_as(request.user.email, 'potencial-member')
24-
return render(request, 'cohorts/webinar_landing_page.html')
23+
return redirect(reverse('payments:member_landing_page'), permanent=False)
2524
return render(request, 'cohorts/webinar_detail.html', {'webinar': facade.find_webinar(slug=slug)})
2625

2726

2827
@login_required
2928
def live_class(request, pk):
3029
if not has_permission(request.user, access_cohorts):
31-
tag_as(request.user.email, 'potencial-member')
32-
return render(request, 'cohorts/live_class_landing_page.html')
30+
return redirect(reverse('payments:member_landing_page'), permanent=False)
3331
return render(request, 'cohorts/live_class_detail.html', {'live_class': facade.find_live_class(pk=pk)})

pythonpro/core/templates/core/lead_thanks.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h1 class="mb-4">Cadastro realizado com Sucesso!</h1>
1717
<p>Será um prazer acompanhar você nessa incrível jornada. Muito obrigado pela confiança em nosso
1818
trabalho!
1919
</p>
20-
<p ">
20+
<p>
2121
Luciano Ramalho e Renzo Nuccitelli
2222
</p>
2323
</div>

pythonpro/discourse/templates/discourse/landing_page.html

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

pythonpro/discourse/tests/test_sso.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from rolepermissions.roles import assign_role
1212

1313
from pythonpro.discourse.views import _decode_payload
14-
from pythonpro.django_assertions import dj_assert_template_used
1514

1615

1716
@pytest.fixture
@@ -130,13 +129,12 @@ def test_user_not_logged(client):
130129
assert response.url == f'{login_path}?next={discourse_path}'
131130

132131

133-
def test_lead_not_able_to_access_forum(client_with_lead, mocker, logged_user):
134-
tag_as = mocker.patch('pythonpro.discourse.views.tag_as')
132+
def test_lead_not_able_to_access_forum(client_with_lead, logged_user):
135133
discourse_path = reverse('discourse:sso')
136134
response = client_with_lead.get(discourse_path, secure=True)
137-
dj_assert_template_used(response, 'discourse/landing_page.html')
138-
tag_as.assert_called_once_with(logged_user.email, 'potencial-member')
135+
assert response.status_code == 302
136+
assert response.url == reverse('payments:member_landing_page')
139137

140138

141139
def test_client_not_able_to_access_forum(client_with_client, mocker, logged_user):
142-
test_lead_not_able_to_access_forum(client_with_client, mocker, logged_user)
140+
test_lead_not_able_to_access_forum(client_with_client, logged_user)

pythonpro/discourse/views.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from django.conf import settings
99
from django.contrib.auth.decorators import login_required
1010
from django.http import HttpResponseRedirect
11-
from django.shortcuts import render
11+
from django.shortcuts import redirect
12+
from django.urls import reverse
1213
from django.views.defaults import bad_request
1314
from rolepermissions.checkers import has_permission
1415

1516
from pythonpro.core.roles import access_forum
16-
from pythonpro.mailchimp.facade import tag_as
1717

1818
logger = Logger(__file__)
1919

@@ -33,8 +33,7 @@ def sso(request):
3333
Code based on https://meta.discourse.org/t/sso-example-for-django/14258
3434
"""
3535
if not has_permission(request.user, access_forum):
36-
tag_as(request.user.email, 'potencial-member')
37-
return render(request, 'discourse/landing_page.html')
36+
return redirect(reverse('payments:member_landing_page'), permanent=False)
3837
payload = request.GET.get('sso')
3938
signature = request.GET.get('sig')
4039
try:

pythonpro/modules/templates/topics/content_member_landing_page.html

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

0 commit comments

Comments
 (0)