Skip to content

Commit e445354

Browse files
committed
adding phone to python birds landing page
1 parent d4ce9b8 commit e445354

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

pythonpro/core/forms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class Meta:
8888
email = forms.EmailField(
8989
label=str(), widget=forms.EmailInput(attrs={'placeholder': 'Qual seu MELHOR e-mail?'})
9090
)
91+
phone = forms.CharField(
92+
label=str(), widget=forms.TextInput(attrs={'placeholder': 'Qual seu número de WHATSAPP?'})
93+
)
9194
source = forms.CharField(widget=forms.HiddenInput())
9295
password1 = forms.CharField(widget=forms.HiddenInput())
9396
password2 = forms.CharField(widget=forms.HiddenInput())

pythonpro/core/templates/core/lead_landing_page.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
<script src="{% static 'js/python-birds/owl.carousel.min.js' %}"></script>
5151
<script src="{% static 'js/python-birds/magnific-popup.min.js' %}"></script>
5252
<script src="{% static 'js/python-birds/main.js' %}"></script>
53+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.min.js" integrity="sha512-pHVGpX7F/27yZ0ISY+VVjyULApbDlD0/X0rgGbTqCE7WFW5MezNTWG/dnhtbBuICzsd0WQPgpE4REBLv+UqChw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
54+
<script type="text/javascript">
55+
jQuery("#id_phone").mask("(00) 000000009");
56+
</script>
5357
{% endblock %}
5458

5559
{% block body %}

pythonpro/core/tests/test_lead_landing_page.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def resp_lead_creation(client, db, fake: Faker, create_lead_mock, email):
8989
data={
9090
'first_name': fake.name(),
9191
'email': email,
92+
'phone': '(11)966922655',
9293
},
9394
secure=True
9495
)
@@ -101,6 +102,7 @@ def test_email_error_subscribing_with_email_variation(resp_lead_creation, email:
101102
data={
102103
'first_name': fake.name(),
103104
'email': email_upercase,
105+
'phone': '(11)966922655',
104106
},
105107
secure=True
106108
)
@@ -116,6 +118,7 @@ def resp_email_upper_case(client, db, fake: Faker, create_lead_mock, email):
116118
data={
117119
'first_name': fake.name(),
118120
'email': email,
121+
'phone': '(11)966922655',
119122
},
120123
secure=True
121124
)
@@ -165,6 +168,7 @@ def resp_lead_creation_without_source(client, db, fake: Faker, create_lead_mock)
165168
data={
166169
'first_name': fake.name(),
167170
'email': fake.email(),
171+
'phone': '(11)966922655',
168172
},
169173
secure=True
170174
)
@@ -189,7 +193,7 @@ def test_user_has_role(resp_lead_creation, django_user_model):
189193
def test_user_created_as_lead_on_email_marketing(resp_lead_creation, django_user_model, create_lead_mock: Mock):
190194
user = django_user_model.objects.first()
191195
create_lead_mock.assert_called_once_with(user.first_name, user.email, 'offer-funnel-0', 'utm_source=facebook',
192-
id=user.id, utm_source='facebook')
196+
phone="11966922655", id=user.id, utm_source='facebook')
193197

194198

195199
def test_user_source_was_saved_from_url(resp_lead_creation, django_user_model, create_lead_mock: Mock):
@@ -276,6 +280,7 @@ def resp_lead_creation_with_utms(client, db, fake: Faker, create_lead_mock, emai
276280
data={
277281
'first_name': fake.name(),
278282
'email': email,
283+
'phone': "(11)966922655",
279284
},
280285
secure=True
281286
)
@@ -292,6 +297,7 @@ def test_should_send_utms_to_email_marketing_as_tags(create_lead_mock, resp_lead
292297
"utm_campaign=a00f00",
293298
"utm_content=content",
294299
"utm_term=term",
300+
phone='11966922655',
295301
id=ANY,
296302
utm_source='facebook-ads'
297303
)

pythonpro/core/views.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,23 @@ def _lead_form(request, *args, **kwargs):
168168
if request.method == 'GET':
169169
form = UserSignupForm()
170170
return render(request, 'core/lead_form_errors.html', context={'form': form})
171-
171+
172+
# TODO: tudo isso deveria ser feito dentro do validation do form. Fiquei com preguiça de arrumar agora
172173
source = request.GET.get('utm_source', default='unknown')
173174
first_name = request.POST.get('first_name')
174175
email = request.POST.get('email')
176+
phone = request.POST.get('phone')
175177
tags = [kwargs.get('offer_tag', 'offer-funnel-0')]
176178
for key, value in request.GET.items():
177179
if key.startswith('utm_'):
178180
tags.append(f"{key}={value}")
179-
181+
182+
phone = phone.replace('(', '')
183+
phone = phone.replace(')', '')
184+
phone = phone.replace(' ', '')
185+
180186
try:
181-
user = user_domain.register_lead(first_name, email, source, tags=tags)
187+
user = user_domain.register_lead(first_name, email, source, phone=phone, tags=tags)
182188
except user_domain.UserCreationException as e:
183189
return render(request, 'core/lead_form_errors.html', context={'form': e.form}, status=400)
184190

pythonpro/domain/user_domain.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
]
2828

2929

30-
def register_lead(first_name: str, email: str, source: str = 'unknown', tags: list = []) -> _User:
30+
def register_lead(first_name: str, email: str, source: str = 'unknown', phone: str = '', tags: list = []) -> _User:
3131
"""
3232
Create a new user on the system generation a random password.
3333
An Welcome email is sent to the user informing his password with the link to change it.
@@ -43,7 +43,9 @@ def register_lead(first_name: str, email: str, source: str = 'unknown', tags: li
4343
source = 'unknown'
4444
_core_facade.validate_user(first_name, email, source)
4545
lead = _core_facade.register_lead(first_name, email, source)
46-
_email_marketing_facade.create_or_update_lead.delay(first_name, email, *tags, id=lead.id, utm_source=source)
46+
_email_marketing_facade.create_or_update_lead.delay(
47+
first_name, email, phone=phone, *tags, id=lead.id, utm_source=source
48+
)
4749

4850
return lead
4951

0 commit comments

Comments
 (0)