def test_item_membership(): config = PagarmeFormConfig.objects.first() item_config = facade.find_payment_item_config('membership') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Inscricão Turma Python Pro', 'membership', 199700, False, config)
def test_item_config_pytools_done(): config = PagarmeFormConfig.objects.first() item_config = facade.find_payment_item_config('pytools-done') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Curso Pytools 50 Off', 'pytools-done', 19850, False, config)
def test_item_config_pytools_oto(): config = PagarmeFormConfig.objects.first() item_config = facade.find_payment_item_config('pytools-oto') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Curso Pytools 75 Off', 'pytools-oto', 9700, False, config)
def test_item_data_science(): config = PagarmeFormConfig.objects.first() item_config = facade.find_payment_item_config('data-science') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Ciência de Dados', 'data-science', 49700, False, config)
def test_item_webdev_oto(first_pagarme_form_config): item_config = facade.find_payment_item_config('webdev-oto') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Webdev Django 50% de Desconto', 'webdev-oto', 49700, False, first_pagarme_form_config)
def test_item_aps(second_pagarme_form_config): item_config = facade.find_payment_item_config('aps') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Acompanhamento de Processos Seletivos', 'aps', 50000, False, second_pagarme_form_config)
def test_item_bootcamp_d1_boleto(second_pagarme_form_config): item_config = facade.find_payment_item_config('bootcamp-d1-boleto') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Bootcamp DevPro - R$1000 Off', 'bootcamp-d1-boleto', 199700, False, second_pagarme_form_config)
def test_item_bootcamp_webdev(first_pagarme_form_config): item_config = facade.find_payment_item_config('bootcamp-webdev') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Bootcamp Python Pro - R$497 Off', 'bootcamp-webdev', 150000, False, first_pagarme_form_config)
def test_item_bootcamp(first_pagarme_form_config): item_config = facade.find_payment_item_config('bootcamp') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Bootcamp Python Pro', 'bootcamp', 199700, False, first_pagarme_form_config)
def test_item_bootcamp_35_discount(first_pagarme_form_config): item_config = facade.find_payment_item_config('bootcamp-35-discount') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Bootcamp Python Pro - 35% de Desconto', 'bootcamp-35-discount', 129700, False, first_pagarme_form_config)
def test_item_bootcamp_50_discount(second_pagarme_form_config): item_config = facade.find_payment_item_config('bootcamp-50-discount') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Bootcamp Python Pro - 50% de Desconto', 'bootcamp-50-discount', 99700, False, second_pagarme_form_config)
def test_item_data_science(first_pagarme_form_config): item_config = facade.find_payment_item_config('data-science') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Ciência de Dados', 'data-science', 49700, False, first_pagarme_form_config)
def test_item_webdev(): config = PagarmeFormConfig.objects.first() item_config = facade.find_payment_item_config('webdev') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Webdev Django', 'webdev', 99700, False, config)
def test_item_webdev_downsell_boleto(second_pagarme_form_config): item_config = facade.find_payment_item_config('webdev-downsell-boleto') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Treinamento Webdev Django', 'webdev-downsell-boleto', 49700, False, second_pagarme_form_config)
def test_item_membership_first_day(first_pagarme_form_config): item_config = facade.find_payment_item_config('membership-first-day') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Inscricão Turma Python Pro 400 R Off', 'membership-first-day', 159700, False, first_pagarme_form_config)
def test_item_config_pytools_oto(first_pagarme_form_config): item_config = facade.find_payment_item_config('pytools-oto') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Curso Pytools 75 Off', 'pytools-oto', 9700, False, first_pagarme_form_config)
def test_item_config_pytools_done(first_pagarme_form_config): item_config = facade.find_payment_item_config('pytools-done') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Curso Pytools 50 Off', 'pytools-done', 19850, False, first_pagarme_form_config)
def test_webinar(first_pagarme_form_config): item_config = facade.find_payment_item_config('treinamento-devpro-webinar') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Treinamento DevPro com 30% de Desconto', 'treinamento-devpro-webinar', 99700, False, first_pagarme_form_config)
def bootcamp_lp_d3_webdev(request): user = request.user has_discount = checkout_facade.has_35_percent_discount() or checkout_facade.has_50_percent_discount() is_debug = bool(request.GET.get('debug', False)) if not is_debug and (has_discount or not (checkout_facade.is_launch_open() and is_webdev(user))): return _redirect_to_bootcamp_lp(request) user_facade.visit_member_landing_page(request.user, source=request.GET.get('utm_source', default='unknown')) has_client_discount = True data = {'name': request.user.first_name, 'email': request.user.email} form = facade.ContactForm(data) has_first_day_discount = False no_discount_item_config = facade.find_payment_item_config('bootcamp') first_day_discount = 0 client_discount_item_config = facade.find_payment_item_config('bootcamp-webdev') promotion_end_date = checkout_facade.launch_datetime_finish payment_item_config = client_discount_item_config client_discount = no_discount_item_config.price - client_discount_item_config.price - first_day_discount return _render_bootcamp_lp(client_discount, first_day_discount, form, has_client_discount, has_first_day_discount, no_discount_item_config, payment_item_config, promotion_end_date, request)
def test_masterclass_oto_boleto(first_pagarme_form_config): item_config = facade.find_payment_item_config( 'treinamento-devpro-masterclass-oto-boleto') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Treinamento DevPro com 30% de Desconto', 'treinamento-devpro-masterclass-oto-boleto', 99700, False, first_pagarme_form_config)
def test_item_membership_for_client_first_day(): config = PagarmeFormConfig.objects.first() item_config = facade.find_payment_item_config( 'membership-client-first-day') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Inscricão Turma Python Pro 500 R Off', 'membership-client-first-day', 149700, False, config)
def _no_wevdev_discount( request, discount_slug, promotion_end_date, template_name='checkout/bootcamp_lp_subscription_open.html'): if request.user.is_authenticated: user_domain.visit_member_landing_page(request.user, source=request.GET.get( 'utm_source', default='unknown')) form = facade.ContactForm() payment_item_config = facade.find_payment_item_config(discount_slug) no_discount_item_config = facade.find_payment_item_config('bootcamp') first_day_discount = no_discount_item_config.price - payment_item_config.price client_discount = 0 has_first_day_discount = True has_client_discount = False return _render_bootcamp_lp(client_discount, first_day_discount, form, has_client_discount, has_first_day_discount, no_discount_item_config, payment_item_config, promotion_end_date, request, template_name)
def get_context_data(self, *args, **kwargs): payment_item_config = facade.find_payment_item_config( 'treinamento-devpro-masterclass-oto') user = self.request.user if user.is_authenticated: data = {'name': user.first_name, 'email': user.email} form = facade.ContactForm(data) else: form = facade.ContactForm() ctx = super().get_context_data(*args, **kwargs) ctx['payment_item_config'] = payment_item_config ctx['contact_form'] = form return ctx
def webdev_landing_page(request): payment_item_config = facade.find_payment_item_config('webdev') user = request.user if user.is_authenticated: data = {'name': user.first_name, 'email': user.email, 'phone': ''} form = facade.ContactForm(data) else: form = facade.ContactForm() ctx = { 'payment_item_config': payment_item_config, 'contact_form': form, } return render(request, 'checkout/webdev_landing_page.html', ctx)
def test_item_python_avancado(free_interest_form_config): item_config = facade.find_payment_item_config( 'pacote-proximo-nivel-67-discount') assert ( item_config.name, item_config.slug, item_config.price, item_config.tangible, item_config.default_config, ) == ('Pacote Python Avançado - 50% de Desconto', 'pacote-proximo-nivel-67-discount', 49700, False, free_interest_form_config) for payment_item in PagarmeItemConfig.objects.filter( slug__startswith='bootcamp').all(): assert payment_item.upsell_id == item_config.id
def webdev_landing_page_oto(request): payment_item_config = facade.find_payment_item_config('webdev-oto') user = request.user if user.is_authenticated: data = {'name': user.first_name, 'email': user.email} form = facade.ContactForm(data) else: form = facade.ContactForm() ctx = { 'payment_item_config': payment_item_config, 'contact_form': form, 'countdown_limit': request.user.date_joined + timedelta(seconds=30 * 60) } return render(request, 'checkout/webdev_landing_page_oto.html', ctx)
def bootcamp_lp_d3(request): user = request.user has_discount = checkout_facade.has_35_percent_discount() or checkout_facade.has_50_percent_discount() or is_webdev( user) is_debug = bool(request.GET.get('debug', False)) if not is_debug and ((not checkout_facade.is_launch_open()) or has_discount): return _redirect_to_bootcamp_lp(request) if request.user.is_authenticated: user_facade.visit_member_landing_page(request.user, source=request.GET.get('utm_source', default='unknown')) form = facade.ContactForm() payment_item_config = no_discount_item_config = facade.find_payment_item_config('bootcamp') first_day_discount = 0 client_discount = 0 has_first_day_discount = False has_client_discount = False promotion_end_date = checkout_facade.launch_datetime_finish return _render_bootcamp_lp(client_discount, first_day_discount, form, has_client_discount, has_first_day_discount, no_discount_item_config, payment_item_config, promotion_end_date, request)
def _webdev_landing_page_50_off(request, template_name, seconds_to_show_full_page=90): payment_item_config = facade.find_payment_item_config('webdev-oto') user = request.user if user.is_authenticated: data = {'name': user.first_name, 'email': user.email} form = facade.ContactForm(data) else: form = facade.ContactForm() countdown_limit = request.user.date_joined + timedelta(days=5) is_promotion_expired = timezone.now() > countdown_limit if request.GET.get('debug') is not None: is_promotion_expired = False ctx = { 'payment_item_config': payment_item_config, 'contact_form': form, 'countdown_limit': countdown_limit, 'is_promotion_expired': is_promotion_expired, 'seconds_to_show_full_page': seconds_to_show_full_page } return render(request, template_name, ctx)
def pytools_oto_lp(request): is_debug = bool(request.GET.get('debug', False)) user = request.user if not (user.is_authenticated or is_debug): return HttpResponseRedirect(reverse('checkout:pytools_lp')) slug = 'pytools-oto' if user.is_authenticated: user_facade.visit_client_landing_page(user, source=request.GET.get( 'utm_source', default='unknown')) data = {'name': user.first_name, 'email': user.email} form = facade.ContactForm(data) else: form = facade.ContactForm() countdown_limit = payment_facade.calculate_oto_expires_datetime( user.date_joined) if not is_debug else now() is_promotion_expired = not ( is_debug or payment_facade.is_on_pytools_oto_season(user.date_joined)) payment_item_config = facade.find_payment_item_config(slug) payment_form_config = payment_item_config.default_config price_float = payment_item_config.price / 100 installments = payment_form_config.max_installments price_installment = payment_form_config.calculate_amount( payment_item_config.price, installments) / installments price_installment /= 100 return render( request, 'checkout/pytools_oto_lp.html', { 'contact_form': form, 'slug': slug, 'payment_item_config': payment_item_config, 'price_float': price_float, 'price_installment': price_installment, 'is_promotion_expired': is_promotion_expired, 'countdown_limit': countdown_limit, })
def active_product_item(execute_migration, cohort, request): slug = request.param return facade.find_payment_item_config(slug)