Ejemplo n.º 1
0
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_domain.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,
                               'checkout/bootcamp_lp_d3.html')
Ejemplo n.º 2
0
def bootcamp_lp_d1(request):
    user = request.user
    is_debug = bool(request.GET.get('debug', False))
    if not is_debug and ((not checkout_facade.has_50_percent_discount()) or is_webdev(user)):
        return _redirect_to_bootcamp_lp(request)

    return _no_wevdev_discount(request, 'bootcamp-50-discount', checkout_facade.discount_50_percent_datetime_limit)
Ejemplo n.º 3
0
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_domain.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,
                               'checkout/bootcamp_lp_d3.html')
Ejemplo n.º 4
0
def availability_strategy(payment_item_config, request):
    if not payment_item_config.is_available():
        return False
    elif request.GET.get('debug', '').lower() == 'true':
        return True
    elif payment_item_config.slug.startswith('bootcamp-webdev'):
        return core_facade.is_webdev(request.user)
    return True
Ejemplo n.º 5
0
def assert_user_promoted(user, slug):
    if slug.startswith('membership'):
        assert core_facade.is_member(user)
    elif slug.startswith('webdev'):
        assert core_facade.is_webdev(user)
    elif slug.startswith('data-science'):
        assert core_facade.is_data_scientist(user)
    elif slug.startswith('bootcamp'):
        assert core_facade.is_bootcamper(user)
    else:
        pytest.fail(f'Invalid slug prefix {slug}')
Ejemplo n.º 6
0
def bootcamp_lp_d2_webdev(request):
    user = request.user
    is_debug = bool(request.GET.get('debug', False))
    if not is_debug and not (checkout_facade.has_35_percent_discount() and is_webdev(user)):
        return _redirect_to_bootcamp_lp(request)
    client_discount_slug = 'bootcamp-webdev-35-discount'
    first_day_discount_slug = 'bootcamp-35-discount'
    promotion_end_date = checkout_facade.discount_35_percent_datetime_limit

    return _render_with_webdev_and_first_day_discounts(request, client_discount_slug, first_day_discount_slug,
                                                       promotion_end_date)
Ejemplo n.º 7
0
def _redirect_to_bootcamp_lp(request):
    if checkout_facade.has_50_percent_discount():
        path_name = 'checkout:bootcamp_lp_d1'
    elif checkout_facade.has_35_percent_discount():
        path_name = 'checkout:bootcamp_lp_d2'
    else:
        path_name = 'checkout:bootcamp_lp_d3'
    if is_webdev(request.user):
        path_name = f'{path_name}_webdev'
    if not checkout_facade.is_launch_open():
        path_name = 'checkout:bootcamp_lp'
    return HttpResponseRedirect(reverse(path_name) + '?' + request.META['QUERY_STRING'])
Ejemplo n.º 8
0
def assert_user_promoted(user, slug):
    if slug.startswith('membership'):
        assert core_facade.is_member(user)
    elif slug.startswith('webdev') or slug == 'treinamento-devpro-webinar':
        assert core_facade.is_webdev(user)
    elif slug.startswith('data-science'):
        assert core_facade.is_data_scientist(user)
    elif slug in {'bootcamp', 'bootcamp-webdev'}:
        assert core_facade.is_bootcamper(user)
        assert core_facade.is_pythonista(
            user)  # bonus because of full paid price
    elif slug.startswith('bootcamp'):
        assert core_facade.is_bootcamper(user)
    elif slug == 'pacote-proximo-nivel-67-discount':
        assert core_facade.is_pythonista(user)
    else:
        pytest.fail(f'Invalid slug prefix {slug}')
def test_user_is_webdev(resp, django_user_model):
    User = django_user_model
    user = User.objects.first()
    assert core_facade.is_webdev(user)
def test_logged_user_become_webdev(resp_logged_user, logged_user):
    assert core_facade.is_webdev(logged_user)