|
1 | 1 | import time |
2 | 2 |
|
3 | | -from django.http import HttpResponseRedirect |
4 | 3 | from django.shortcuts import render, redirect |
5 | 4 | from django.urls import reverse |
6 | 5 | from django.utils.http import urlencode |
7 | | -from django.utils.timezone import now |
8 | 6 | from django_pagarme import facade |
9 | 7 |
|
10 | 8 | from pythonpro.checkout import facade as checkout_facade |
11 | 9 | from pythonpro.checkout import forms as checkout_forms |
12 | 10 | from pythonpro.checkout.forms import WaitingForm |
13 | 11 | from pythonpro.core.facade import is_client |
14 | 12 | from pythonpro.domain import user_facade |
15 | | -from pythonpro.payments import facade as payment_facade |
16 | | - |
17 | | - |
18 | | -def pytools_lp(request): |
19 | | - user = request.user |
20 | | - slug = 'pytools' |
21 | | - if user.is_authenticated: |
22 | | - user_facade.visit_client_landing_page(user, source=request.GET.get('utm_source', default='unknown')) |
23 | | - data = {'name': user.first_name, 'email': user.email} |
24 | | - form = facade.ContactForm(data) |
25 | | - else: |
26 | | - form = facade.ContactForm() |
27 | | - user_creation = user.date_joined if user.is_authenticated else now() |
28 | | - is_promotion_season = payment_facade.is_on_pytools_promotion_season(user_creation) |
29 | | - payment_item_config = facade.find_payment_item_config(slug) |
30 | | - payment_form_config = payment_item_config.default_config |
31 | | - price_float = payment_item_config.price / 100 |
32 | | - installments = payment_form_config.max_installments |
33 | | - price_installment = payment_form_config.calculate_amount(payment_item_config.price, installments) / installments |
34 | | - price_installment /= 100 |
35 | | - _, promotion_end_date = payment_facade.calculate_pytools_promotion_interval() |
36 | | - return render( |
37 | | - request, |
38 | | - 'checkout/pytools_lp.html', { |
39 | | - 'contact_form': form, |
40 | | - 'slug': slug, |
41 | | - 'payment_item_config': payment_item_config, |
42 | | - 'price_float': price_float, |
43 | | - 'price_installment': price_installment, |
44 | | - 'is_promotion_season': is_promotion_season, |
45 | | - 'promotion_end_date': promotion_end_date, |
46 | | - 'is_promotion_expired': False, |
47 | | - }) |
48 | | - |
49 | | - |
50 | | -def pytools_oto_lp(request): |
51 | | - is_debug = bool(request.GET.get('debug', False)) |
52 | | - user = request.user |
53 | | - if not (user.is_authenticated or is_debug): |
54 | | - return HttpResponseRedirect(reverse('checkout:pytools_lp')) |
55 | | - |
56 | | - slug = 'pytools-oto' |
57 | | - if user.is_authenticated: |
58 | | - user_facade.visit_client_landing_page(user, source=request.GET.get('utm_source', default='unknown')) |
59 | | - data = {'name': user.first_name, 'email': user.email} |
60 | | - form = facade.ContactForm(data) |
61 | | - else: |
62 | | - form = facade.ContactForm() |
63 | | - countdown_limit = payment_facade.calculate_oto_expires_datetime(user.date_joined) if not is_debug else now() |
64 | | - is_promotion_expired = not (is_debug or payment_facade.is_on_pytools_oto_season(user.date_joined)) |
65 | | - payment_item_config = facade.find_payment_item_config(slug) |
66 | | - payment_form_config = payment_item_config.default_config |
67 | | - price_float = payment_item_config.price / 100 |
68 | | - installments = payment_form_config.max_installments |
69 | | - price_installment = payment_form_config.calculate_amount(payment_item_config.price, installments) / installments |
70 | | - price_installment /= 100 |
71 | | - return render( |
72 | | - request, |
73 | | - 'checkout/pytools_oto_lp.html', { |
74 | | - 'contact_form': form, |
75 | | - 'slug': slug, |
76 | | - 'payment_item_config': payment_item_config, |
77 | | - 'price_float': price_float, |
78 | | - 'price_installment': price_installment, |
79 | | - 'is_promotion_expired': is_promotion_expired, |
80 | | - 'countdown_limit': countdown_limit, |
81 | | - }) |
82 | 13 |
|
83 | 14 |
|
84 | 15 | def membership_lp(request): |
|
0 commit comments