Skip to content

Commit 9a12c0f

Browse files
renzonrenzon
authored andcommitted
Criado esboço de página de CPL 1
hold #1564 Deve ser testado em produção para ver se cometários do facebook aparecem
1 parent 111ca1c commit 9a12c0f

File tree

8 files changed

+251
-4
lines changed

8 files changed

+251
-4
lines changed

pythonpro/core/facade.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ def subscribe_to_launch(user: User, source: str):
125125
return UserInteraction(category=UserInteraction.LAUNCH_SUBSCRIPTION, source=source, user=user).save()
126126

127127

128+
def visit_cpl1(user: User, source: str):
129+
return UserInteraction(category=UserInteraction.CPL1, source=source, user=user).save()
130+
131+
132+
def visit_cpl2(user: User, source: str):
133+
return UserInteraction(category=UserInteraction.CPL2, source=source, user=user).save()
134+
135+
136+
def visit_cpl3(user: User, source: str):
137+
return UserInteraction(category=UserInteraction.CPL3, source=source, user=user).save()
138+
139+
128140
def find_leads_by_date_joined_interval(begin: datetime, end: datetime):
129141
return list(user for user in User.objects.filter(date_joined__gte=begin, date_joined__lte=end).all() if
130142
not has_role(user, ['client', 'member']))

pythonpro/core/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class Meta:
9090
BECOME_MEMBER = 'BECOME_MEMBER'
9191
LAUNCH_LP = 'LAUNCH_LP'
9292
LAUNCH_SUBSCRIPTION = 'LAUNCH_SUBSCRIPTION'
93+
CPL1 = 'CPL1'
94+
CPL2 = 'CPL2'
95+
CPL3 = 'CPL3'
9396

9497
user = models.ForeignKey(User, on_delete=models.CASCADE)
9598
creation = models.DateTimeField(auto_now_add=True)
@@ -110,6 +113,9 @@ class Meta:
110113
(BECOME_MEMBER, 'User Become Member'),
111114
(LAUNCH_LP, 'User visited Launch Landing Page'),
112115
(LAUNCH_SUBSCRIPTION, 'User subscribed to launch'),
116+
(CPL1, 'User Visited CPL1'),
117+
(CPL2, 'User Visited CPL2'),
118+
(CPL3, 'User Visited CPL3'),
113119
)
114120
)
115121
)

pythonpro/domain/user_facade.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,36 @@ def activate_user(user: _User, source: str) -> None:
306306
"""
307307
_core_facade.activate_user(user, source)
308308
_mailchimp_facade.remove_tags(user.email, 'never-watched-video')
309+
310+
311+
def visit_cpl1(user: _User, source: str) -> None:
312+
"""
313+
User visit CPL1
314+
:param user:
315+
:param source:
316+
:return:
317+
"""
318+
_core_facade.visit_cpl1(user, source)
319+
_mailchimp_facade.tag_as(user.email, 'cpl1')
320+
321+
322+
def visit_cpl2(user: _User, source: str) -> None:
323+
"""
324+
User visit CPL2
325+
:param user:
326+
:param source:
327+
:return:
328+
"""
329+
_core_facade.visit_cpl2(user, source)
330+
_mailchimp_facade.tag_as(user.email, 'cpl2')
331+
332+
333+
def visit_cpl3(user: _User, source: str) -> None:
334+
"""
335+
User visit CPL2
336+
:param user:
337+
:param source:
338+
:return:
339+
"""
340+
_core_facade.visit_cpl3(user, source)
341+
_mailchimp_facade.tag_as(user.email, 'cpl3')
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{% extends 'core/base_without_nav.html' %}
2+
{% load static %}
3+
{% block title %}{{ title }}{% endblock %}
4+
{% block description %}{{ description }}{% endblock %}
5+
{% block head %}
6+
<link rel='stylesheet' href='https://unpkg.com/emoji.css/dist/emoji.min.css'>
7+
8+
<style>
9+
@font-face {
10+
font-family: 'Gilroy-Bold';
11+
font-style: normal;
12+
font-weight: normal;
13+
src: local('Gilroy-Bold ☞'), url('{% static "fonts/Gilroy-Bold.woff" %}') format('woff');
14+
}
15+
16+
@font-face {
17+
font-family: 'Gilroy-Heavy';
18+
font-style: normal;
19+
font-weight: normal;
20+
src: local('Gilroy-Heavy ☞'), url('{% static "fonts/Gilroy-Heavy.woff" %}') format('woff');
21+
}
22+
23+
@font-face {
24+
font-family: 'Gilroy-Light';
25+
font-style: normal;
26+
font-weight: normal;
27+
src: local('Gilroy-Light ☞'), url('{% static "fonts/Gilroy-Light.woff" %}') format('woff');
28+
}
29+
30+
@font-face {
31+
font-family: 'Gilroy-Medium';
32+
font-style: normal;
33+
font-weight: normal;
34+
src: local('Gilroy-Medium ☞'), url('{% static "fonts/Gilroy-Medium.woff" %}') format('woff');
35+
}
36+
37+
@font-face {
38+
font-family: 'Gilroy-Regular';
39+
font-style: normal;
40+
font-weight: normal;
41+
src: local('Gilroy-Regular ☞'), url('{% static "fonts/Gilroy-Regular.woff" %}') format('woff');
42+
}
43+
44+
</style>
45+
<link rel="stylesheet" href="{% static 'css/client.css' %}"/>
46+
47+
<style>
48+
h1 {
49+
font-size: 3.2rem;
50+
}
51+
52+
input.form-control, button.btn {
53+
border-radius: 0px;
54+
margin: 5px 0;
55+
font-family: 'ubuntu';
56+
}
57+
58+
button.btn {
59+
border-width: 1px;
60+
font-family: 'Gilroy-Bold';
61+
}
62+
63+
.mobile h1 {
64+
font-size: 2rem;
65+
margin-bottom: 30px;
66+
}
67+
68+
.mobile h2 {
69+
font-size: 1.5rem;
70+
}
71+
72+
.mobile.hero {
73+
margin: 20px 0;
74+
}
75+
</style>
76+
{% endblock head %}
77+
78+
{% block body %}
79+
<div class=''>
80+
<div class="container">
81+
<div class="row text-center">
82+
<!-- desktop -->
83+
<div class="col-md-12 hero desktop d-none d-sm-block d-md-block">
84+
<h1 class='font-weight-bold' style='color: #44A5F1'>
85+
SEMANA DO PROGRAMADOR PROFISSIONAL
86+
</h1>
87+
<h2 class='col-md-8 offset-md-2'>
88+
Uma semana de vídeos e aulas que vão te ensinar como se
89+
<b>tornar um programador profissional</b> em pouco tempo!
90+
</h2>
91+
<h3 class='font-weight-bold col-md-8 offset-md-2 mt-4'>28/10 á 01/11</h3>
92+
</div>
93+
94+
<!-- mobile -->
95+
<div class="col-md-12 hero mobile d-block d-lg-none d-xl-none">
96+
<h1 class='font-weight-bold' style='color: #44A5F1'>
97+
SEMANA DO PROGRAMADOR PROFISSIONAL
98+
</h1>
99+
<h2 class='col-md-8 offset-md-2'>
100+
Uma semana de vídeos e aulas que vão te ensinar como se
101+
<b>tornar um programador profissional</b> em pouco tempo!
102+
</h2>
103+
<h3 class='font-weight-bold col-md-8 offset-md-2 mt-4'>28/10 á 01/11</h3>
104+
</div>
105+
</div>
106+
</div>
107+
</div>
108+
109+
<div class='bg-primary'>
110+
<div class="container">
111+
<div class="row text-center">
112+
<div class="col hero">
113+
<iframe width="560" height="315" src="https://www.youtube.com/embed/{{ video_id }}" frameborder="0"
114+
allowfullscreen></iframe>
115+
</div>
116+
</div>
117+
</div>
118+
</div>
119+
120+
<div class="container">
121+
<div class="row">
122+
<div class="col mb-5 mt-5">
123+
<div id="fb-root"></div>
124+
<script async defer crossorigin="anonymous"
125+
src="https://connect.facebook.net/pt_BR/sdk.js#xfbml=1&version=v4.0&appId=1432926893644944&autoLogAppEvents=1"></script>
126+
<div class="fb-comment-embed" data-href="{{ data_href }}" data-width="560" data-include-parent="false"></div>
127+
128+
</div>
129+
</div>
130+
</div>
131+
132+
<div class='bg-primary pt-5 pb-5'>
133+
<div class="container text-white">
134+
{% include 'core/social_proof.html' %}
135+
</div>
136+
</div>
137+
138+
{% endblock body %}

pythonpro/launch/templates/launch/landing_page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends 'core/base_without_nav.html' %}
22
{% load static %}
33
{% block title %}Inscrições abertas! Semana do Programador Profissional{% endblock %}
4-
{% block description %}Página de Inscrição para Semana do Programdor Profissional{% endblock %}
4+
{% block description %}Página de Inscrição para Semana do Programador Profissional{% endblock %}
55
{% block head %}
66
<link rel='stylesheet' href='https://unpkg.com/emoji.css/dist/emoji.min.css'>
77

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import pytest
2+
from django.urls import reverse
3+
4+
from pythonpro.django_assertions import dj_assert_contains
5+
from pythonpro.domain.user_facade import find_user_interactions
6+
7+
8+
@pytest.fixture
9+
def tag_as_mock(mocker):
10+
return mocker.patch('pythonpro.domain.user_facade._mailchimp_facade.tag_as')
11+
12+
13+
@pytest.fixture
14+
def resp(client, tag_as_mock):
15+
return client.get(reverse('launch:cpl1'), secure=True)
16+
17+
18+
def test_status_code(resp):
19+
assert 200 == resp.status_code
20+
21+
22+
def test_mailchimp_tag_not_called(resp, tag_as_mock):
23+
assert tag_as_mock.call_count == 0
24+
25+
26+
def test_cpl_video_is_present(resp):
27+
dj_assert_contains(resp, 'https://www.youtube.com/embed/')
28+
29+
30+
def test_facebook_comments_is_present(resp):
31+
dj_assert_contains(resp, f'<div class="fb-comment-embed" data-href="https://localhost{reverse("launch:cpl1")}')
32+
33+
34+
@pytest.fixture
35+
def resp_with_user(client_with_user, tag_as_mock):
36+
return client_with_user.get(reverse('launch:cpl1'), secure=True)
37+
38+
39+
def test_user_interaction(resp_with_user, logged_user):
40+
assert 'CPL1' in [i.category for i in find_user_interactions(logged_user)]
41+
42+
43+
def test_mailchimp_tag(resp_with_user, logged_user, tag_as_mock):
44+
tag_as_mock.assert_called_once_with(logged_user.email, 'cpl1')

pythonpro/launch/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
path('semana-do-programador-profissional/inscricao', views.landing_page, name='landing_page'),
88
path('semana-do-programador-profissional/form', views.lead_form, name='lead_form'),
99
path('semana-do-programador-profissional/obrigado', views.ty, name='ty'),
10+
path('semana-do-programador-profissional/faculdade-nao-prepara-para-o-mercado', views.cpl1, name='cpl1'),
1011
]

pythonpro/launch/views.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Create your views here.
33
from django.urls import reverse
44

5+
from pythonpro.absolute_uri import build_absolute_uri
56
from pythonpro.cohorts.facade import find_most_recent_cohort
67
from pythonpro.domain import user_facade
78
from pythonpro.launch.forms import LeadForm
@@ -37,8 +38,20 @@ def lead_form(request):
3738

3839
def ty(request):
3940
user = request.user
40-
cohort_slug = find_most_recent_cohort().slug
41-
python_birds_path = reverse('core:lead_landing') + f'?utm_source=lancamento-{cohort_slug}'
4241
if user.is_authenticated:
4342
user_facade.subscribe_launch_landing_page(user, request.GET.get('utm_source', 'unknown'))
44-
return render(request, 'launch/ty.html', {'python_birds_path': python_birds_path})
43+
return render(request, 'launch/ty.html')
44+
45+
46+
def cpl1(request):
47+
user = request.user
48+
if user.is_authenticated:
49+
user_facade.visit_cpl1(user, request.GET.get('utm_source', 'unknown'))
50+
51+
ctx = {
52+
'data_href': f'https://{build_absolute_uri(request.path)}',
53+
'video_id': 'ZCuxX4vyFTo',
54+
'title': 'A Faculdade não te prepara para o mercado!',
55+
'description': 'Primeira Aula da Semana do Programador Profissional: A Faculdade não te prepara para o mercado!'
56+
}
57+
return render(request, 'launch/cpl1.html', ctx)

0 commit comments

Comments
 (0)