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 waiting_list_ty(request): user_facade.subscribe_to_waiting_list(request.user, source=request.GET.get( 'utm_source', default='unknown')) return render(request, 'payments/waiting_list_ty.html', {'email': request.user.email})
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)