Skip to content

Commit b457813

Browse files
renzonrenzon
authored andcommitted
Removed Analytics App Middleware
part of #4517
1 parent 194e5fc commit b457813

7 files changed

Lines changed: 13 additions & 59 deletions

File tree

pythonpro/analytics/tests/test_middleware.py

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

pythonpro/domain/user_domain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def subscribe_to_waiting_list(session_id, user: _User, phone: str, source: str)
247247
"""
248248
_core_facade.subscribe_to_waiting_list(user, source)
249249
subscribe_with_no_role.delay(
250-
session_id, user.first_name, user.email, 'lista-de-espera', id=user.id, phone=phone
250+
None, user.first_name, user.email, 'lista-de-espera', id=user.id, phone=phone
251251
)
252252

253253

@@ -264,9 +264,9 @@ def subscribe_anonymous_user_to_waiting_list(session_id, email: str, name: str,
264264
try:
265265
user = _core_facade.find_user_by_email(email)
266266
except _User.DoesNotExist:
267-
subscribe_with_no_role.delay(session_id, name, email, 'lista-de-espera', phone=phone)
267+
subscribe_with_no_role.delay(None, name, email, 'lista-de-espera', phone=phone)
268268
else:
269-
subscribe_to_waiting_list(session_id, user, phone, source)
269+
subscribe_to_waiting_list(None, user, phone, source)
270270

271271

272272
def activate_user(user: _User, source: str) -> None:

pythonpro/launch/tests/test_lead_form.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def resp_with_user(client_with_user, logged_user, cohort, subscribe_with_no_role
8181

8282
def test_user_first_name(resp_with_user, logged_user, subscribe_with_no_role, cohort):
8383
subscribe_with_no_role.assert_called_once_with(
84-
resp_with_user.cookies['sessionid'].value,
84+
None,
8585
'Moacir',
8686
logged_user.email,
8787
f'turma-{cohort.slug}-semana-do-programador',

pythonpro/launch/views.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from pythonpro.absolute_uri import build_absolute_uri
99
from pythonpro.cohorts.facade import find_most_recent_cohort
10-
from pythonpro.domain import user_domain
1110
from pythonpro.domain import subscription_domain
11+
from pythonpro.domain import user_domain
1212
from pythonpro.launch.facade import (
1313
get_launch_status,
1414
get_opened_cpls,
@@ -40,16 +40,15 @@ def lead_form(request):
4040
email = form.cleaned_data['email']
4141
first_name = form.cleaned_data['name']
4242
user = request.user
43-
session_id = request.session.session_key
4443
if user.is_authenticated:
4544
subscription_domain.subscribe_with_no_role.delay(
46-
session_id,
45+
None,
4746
first_name,
4847
email,
4948
f'turma-{find_most_recent_cohort().slug}-semana-do-programador', id=user.id)
5049
else:
5150
subscription_domain.subscribe_with_no_role.delay(
52-
session_id,
51+
None,
5352
first_name,
5453
email,
5554
f'turma-{find_most_recent_cohort().slug}-semana-do-programador')

pythonpro/pages/tests/test_bootcamp_vip_landing_page.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def test_should_call_update_when_with_correct_parameters(subscribe_with_no_role,
6565

6666
# TODO: move this phone tests do generic context
6767
def test_should_call_update_when_logged_with_correct_parameters(subscribe_with_no_role, client_with_user):
68-
resp_with_user = client_with_user.post(
68+
client_with_user.post(
6969
reverse('pages:bootcamp_vip_landing_page'),
7070
{'name': 'Moacir', 'email': 'moacir@python.pro.br', 'phone': '(11) 99999-9999'},
7171
secure=True
7272
)
7373

7474
subscribe_with_no_role.assert_called_with(
75-
resp_with_user.cookies['sessionid'].value,
75+
None,
7676
'Moacir',
7777
'moacir@python.pro.br',
7878
mock.ANY,

pythonpro/pages/views.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from datetime import timedelta
2-
from inflection import underscore
32

4-
from django.views.generic import FormView, TemplateView
53
from django.urls import reverse_lazy
64
from django.utils import timezone
5+
from django.views.generic import FormView, TemplateView
76
from django_pagarme import facade
7+
from inflection import underscore
88

99
from pythonpro.cohorts.facade import find_most_recent_cohort
10-
from pythonpro.pages.forms import NameEmailForm, NameEmailPhoneForm
1110
from pythonpro.domain.subscription_domain import subscribe_with_no_role
11+
from pythonpro.pages.forms import NameEmailForm, NameEmailPhoneForm
1212

1313

1414
class TemplateNameMixin:
@@ -36,8 +36,7 @@ def form_valid(self, form):
3636
kwargs['id'] = self.request.user.id
3737
kwargs['phone'] = f"+55{form.cleaned_data['phone']}"
3838

39-
session_id = self.request.session.session_key
40-
subscribe_with_no_role.delay(session_id, *args, **kwargs)
39+
subscribe_with_no_role.delay(None, *args, **kwargs)
4140
return super().form_valid(form)
4241

4342

pythonpro/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
'django_otp.middleware.OTPMiddleware',
121121
'django.contrib.messages.middleware.MessageMiddleware',
122122
'django.middleware.clickjacking.XFrameOptionsMiddleware',
123-
'pythonpro.analytics.middleware.AnalyticsMiddleware',
124123
]
125124

126125
if DEBUG:

0 commit comments

Comments
 (0)