def member_landing_page(request): user = request.user if user.is_authenticated: user_facade.visit_member_landing_page(request.user, source=request.GET.get( 'utm_source', default='unknown')) notification_url = reverse('payments:membership_notification', kwargs={'user_id': user.id}) else: notification_url = reverse( 'payments:membership_anonymous_notification') if settings.SUBSCRIPTIONS_OPEN: template = 'payments/member_landing_page_subscription_open.html' price = membership_facade.calculate_membership_price(user) price_float = price / 100 price_installment = (price // 10) / 100 return render( request, template, { 'PAGARME_CRYPTO_KEY': settings.PAGARME_CRYPTO_KEY, 'price': price, 'price_float': price_float, 'price_installment': price_installment, 'notification_url': request.build_absolute_uri(notification_url), 'cohort': cohorts_facade.find_most_recent_cohort() }) else: template = 'payments/member_landing_page_subscription_closed.html' return render(request, template, {})
def _render_launch_page(is_launch_open, request, template_closed_launch, template_open_launch, redirect_path_name: str): user = request.user if user.is_authenticated: user_facade.visit_member_landing_page(request.user, source=request.GET.get( 'utm_source', default='unknown')) template = template_closed_launch return render(request, template, {})
def _no_wevdev_discount(request, discount_slug, promotion_end_date): 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 = 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)
def _render_with_webdev_and_first_day_discounts(request, client_discount_slug, first_day_discount_slug, promotion_end_date): 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 = True no_discount_item_config = facade.find_payment_item_config('bootcamp') first_day_discount_item_config = facade.find_payment_item_config(first_day_discount_slug) first_day_discount = no_discount_item_config.price - first_day_discount_item_config.price client_discount_item_config = facade.find_payment_item_config(client_discount_slug) 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 _render_launch_page(is_launch_open, request, template_closed_launch, template_open_launch, redirect_path_name: str): user = request.user if user.is_authenticated: user_facade.visit_member_landing_page(request.user, source=request.GET.get( 'utm_source', default='unknown')) notification_url = reverse('payments:membership_notification', kwargs={'user_id': user.id}) else: notification_url = reverse( 'payments:membership_anonymous_notification') if is_launch_open: template = template_open_launch discount = membership_facade.calculate_discount(user) discount_float = discount / 100 price = membership_facade.calculate_membership_price(user) price_float = price / 100 full_price_float = price_float + discount_float price_installment = (price // 10) / 100 full_price_installment = full_price_float // 10 login_url = reverse('login') redirect_path = reverse(redirect_path_name) qs = urlencode( {'utm_source': request.GET.get('utm_source', 'unknown')}) redirect_url = f'{redirect_path}?{qs}' qs = urlencode({'next': redirect_url}) login_url = f'{login_url}?{qs}' return render( request, template, { 'PAGARME_CRYPTO_KEY': settings.PAGARME_CRYPTO_KEY, 'price': price, 'price_float': price_float, 'price_installment': price_installment, 'notification_url': request.build_absolute_uri(notification_url), 'cohort': cohorts_facade.find_most_recent_cohort(), 'has_discount': discount_float > 0, 'discount_float': discount_float, 'full_price_installment': full_price_installment, 'full_price_float': full_price_float, 'login_url': login_url, }) else: template = template_closed_launch return render(request, template, {})
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 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 bootcamp_lp(request): if request.method == 'POST': form = WaitingForm(request.POST) if form.is_valid(): source = request.GET.get('utm_source', default='unknown') data = form.cleaned_data if request.user.is_authenticated: user_facade.subscribe_to_waiting_list(request.user, data['phone'], source) else: user_facade.subscribe_anonymous_user_to_waiting_list( data['email'], data['first_name'], data['phone'], source ) return redirect(reverse('checkout:waiting_list_ty')) return render(request, 'checkout/bootcamp_lp_subscription_closed.html', {'form': form}) if not checkout_facade.is_launch_open(): if request.user.is_authenticated: user_facade.visit_member_landing_page(request.user, source=request.GET.get('utm_source', default='unknown')) form = checkout_forms.WaitingForm() return render(request, 'checkout/bootcamp_lp_subscription_closed.html', {'form': form}) return _redirect_to_bootcamp_lp(request)
def membership_lp(request): user = request.user if request.method == 'POST': form = WaitingForm(request.POST) if form.is_valid(): source = request.GET.get('utm_source', default='unknown') data = form.cleaned_data if user.is_authenticated: user_facade.subscribe_to_waiting_list(request.user, data['phone'], source) else: user_facade.subscribe_anonymous_user_to_waiting_list( data['email'], data['first_name'], data['phone'], source) return redirect(reverse('checkout:waiting_list_ty')) else: return render(request, 'checkout/membership_lp_subscription_closed.html', {'form': form}) if user.is_authenticated: user_facade.visit_member_landing_page(request.user, source=request.GET.get( 'utm_source', default='unknown')) is_debug = bool(request.GET.get('debug', False)) should_show_closed_subscription_page = not ( is_debug or checkout_facade.is_launch_open()) if should_show_closed_subscription_page: form = checkout_forms.WaitingForm() return render(request, 'checkout/membership_lp_subscription_closed.html', {'form': form}) has_client_discount = False if user.is_authenticated: has_client_discount = is_client(user) data = {'name': user.first_name, 'email': user.email} form = facade.ContactForm(data) else: form = facade.ContactForm() has_first_day_discount = checkout_facade.is_launch_first_day_discount( ) or is_debug no_discount_item_config = facade.find_payment_item_config('membership') payment_item_config = no_discount_item_config client_discount = 0 first_day_discount = 0 client_discount_slug = 'membership-client' if has_first_day_discount: first_day_discount_item_config = facade.find_payment_item_config( 'membership-first-day') payment_item_config = first_day_discount_item_config first_day_discount = no_discount_item_config.price - first_day_discount_item_config.price if has_client_discount: client_discount_slug = 'membership-client-first-day' if has_client_discount: client_discount_item_config = facade.find_payment_item_config( client_discount_slug) payment_item_config = client_discount_item_config client_discount = no_discount_item_config.price - client_discount_item_config.price - first_day_discount login_url = reverse('two_factor:login') redirect_path = reverse('checkout:membership_lp') qs = urlencode({'utm_source': request.GET.get('utm_source', 'unknown')}) redirect_url = f'{redirect_path}?{qs}' qs = urlencode({'next': redirect_url}) login_url = f'{login_url}?{qs}' promotion_end_date = (checkout_facade.discount_datetime_limit if has_first_day_discount else checkout_facade.launch_datetime_finish) # Seconds to milliseconds https://stackoverflow.com/questions/5022447/converting-date-from-python-to-javascript promotion_end_date_milliseconds = int( time.mktime(promotion_end_date.timetuple())) * 1000 context = { 'launch_datetime_finish': checkout_facade.launch_datetime_finish, 'discount_datetime_limit': checkout_facade.discount_datetime_limit, 'payment_item_config': payment_item_config, 'contact_form': form, 'login_url': login_url, 'has_first_day_discount': has_first_day_discount, 'has_client_discount': has_client_discount, 'client_discount': client_discount, 'first_day_discount': first_day_discount, 'promotion_end_date': promotion_end_date, 'promotion_end_date_milliseconds': promotion_end_date_milliseconds, 'no_discount_item_config': no_discount_item_config, } return render(request, 'checkout/membership_lp_subscription_open.html', context)