Skip to content

Commit 7376858

Browse files
renzonrenzon
authored andcommitted
Fixed debug on sell pages and countdown on botton of pages
close #2676
1 parent 3d8250f commit 7376858

3 files changed

Lines changed: 34 additions & 9 deletions

File tree

‎pythonpro/checkout/tests/test_bootcamp_lp_when_subscription_open.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ def test_no_user_no_discount_after_launch_with_debug(resp_no_user_after_launch_w
5454
assert resp_no_user_after_launch_with_debug.context['payment_item_config'].slug == 'bootcamp'
5555

5656

57+
@pytest.fixture(params=[
58+
'checkout:bootcamp_lp_d1',
59+
'checkout:bootcamp_lp_d2',
60+
'checkout:bootcamp_lp_d3',
61+
'checkout:bootcamp_lp_d1_webdev',
62+
'checkout:bootcamp_lp_d2_webdev',
63+
'checkout:bootcamp_lp_d3_webdev',
64+
])
65+
def resp_debug_all_lp_after_lanch(client_with_lead, tag_as_mock, freezer, request, logged_user):
66+
freezer.move_to(facade.launch_datetime_finish + timedelta(seconds=1))
67+
client_with_lead.force_login(logged_user)
68+
return client_with_lead.get(reverse(request.param), data={'debug': 'true'})
69+
70+
71+
def test_status_code_200_eg_no_redirect(resp_debug_all_lp_after_lanch):
72+
assert resp_debug_all_lp_after_lanch.status_code == 200
73+
74+
5775
@pytest.fixture
5876
def resp_no_user_with_50_discount(client, tag_as_mock, freezer):
5977
freezer.move_to(facade.discount_50_percent_datetime_limit - timedelta(seconds=1))

‎pythonpro/checkout/views.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def bootcamp_lp_d1(request):
101101
@login_required
102102
def bootcamp_lp_d1_webdev(request):
103103
user = request.user
104-
if not (checkout_facade.has_50_percent_discount() and is_webdev(user)):
104+
is_debug = bool(request.GET.get('debug', False))
105+
if not is_debug and not (checkout_facade.has_50_percent_discount() and is_webdev(user)):
105106
return _redirect_to_bootcamp_lp(request)
106107

107108
client_discount_slug = 'bootcamp-webdev-50-discount'
@@ -115,7 +116,7 @@ def bootcamp_lp_d1_webdev(request):
115116
def bootcamp_lp_d2(request):
116117
user = request.user
117118
is_debug = bool(request.GET.get('debug', False))
118-
if not is_debug and (not checkout_facade.has_35_percent_discount()) or is_webdev(user):
119+
if not is_debug and (not checkout_facade.has_35_percent_discount() or is_webdev(user)):
119120
return _redirect_to_bootcamp_lp(request)
120121

121122
return _no_wevdev_discount(request, 'bootcamp-35-discount', checkout_facade.discount_35_percent_datetime_limit)
@@ -161,7 +162,8 @@ def bootcamp_lp_d3(request):
161162
def bootcamp_lp_d3_webdev(request):
162163
user = request.user
163164
has_discount = checkout_facade.has_35_percent_discount() or checkout_facade.has_50_percent_discount()
164-
if has_discount or not (checkout_facade.is_launch_open() and is_webdev(user)):
165+
is_debug = bool(request.GET.get('debug', False))
166+
if not is_debug and (has_discount or not (checkout_facade.is_launch_open() and is_webdev(user))):
165167
return _redirect_to_bootcamp_lp(request)
166168

167169
user_facade.visit_member_landing_page(request.user, source=request.GET.get('utm_source', default='unknown'))

‎pythonpro/core/static/js/spp/countdown.js‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@ function initCountDown(countDown) {
44
hour = minute * 60,
55
day = hour * 24;
66
x = setInterval(function () {
7-
87
let now = new Date().getTime(),
98
distance = countDown - now;
109

11-
document.getElementsByClassName('days')[0].innerText = Math.floor(distance / (day));
12-
document.getElementsByClassName('hours')[0].innerText = Math.floor((distance % (day)) / (hour));
13-
document.getElementsByClassName('minutes')[0].innerText = Math.floor((distance % (hour)) / (minute));
14-
document.getElementsByClassName('seconds')[0].innerText = Math.floor((distance % (minute)) / second);
10+
let data = {
11+
'days': distance / (day),
12+
'hours': (distance % (day)) / (hour),
13+
'minutes': (distance % (hour)) / (minute),
14+
'seconds': (distance % (minute)) / second
15+
};
16+
for (let prop in data) {
17+
for (let element of document.getElementsByClassName(prop)) {
18+
element.innerText = Math.floor(data[prop]);
19+
}
20+
}
1521

1622
if (distance < 0) {
1723
clearInterval(x);
1824
'Tempo esgotado!';
1925
}
20-
2126
}, second)
2227
}

0 commit comments

Comments
 (0)