def get_all_rental_plans_info(request): result = [] # Campaign #6 -- Commission Junction # Campaign #13 -- Neverblue if not request.user.is_authenticated() and request.campaign_id in ['6', '13']: plans = [RentalPlan.PlanA, RentalPlan.PlanB] else: plans = [RentalPlan.PlanA, RentalPlan.PlanB, RentalPlan.PlanD, RentalPlan.PlanE, RentalPlan.PlanC] for plan in plans: _plan = RentalPlan.get_details2(plan, request) or {} _plan.update({ 'price_display': RentalPlan.get_price_display(plan), 'allowed': RentalPlan.get_allowed_games_amount(plan), }) result.append(_plan) return result
def create(request, initial=None, all_plans=False): plan = request.POST.get('0-plan') if plan is not None: plan = RentalPlan.get_details2(int(plan), request) profile = request.user.get_profile() cc_data = profile.get_billing_card_data() initial = { 1: cc_data, } if all_plans: plan_form = AllPlansPaymentPlanForm all_plans_info = get_all_rental_plans_info(request) else: plan_form = PaymentPlanForm all_plans_info = get_all_rental_plans_info(request) # Setting context # current_rental_plan already here from context processor plans = NewRentalPlan.objects.available_for_change(request) limited_plans = [p for p in plans if p.out_per_month] unlimited_plans = [p for p in plans if not p.out_per_month] # --- request.rent_wizard = ChangeRentPlanWizard('members/rent/wizards/change_plan.html', [plan_form, ConfirmPlanChangingForm], initial=initial, title='Change Plan', form_kwargs={ 0: {'request': request, }, 1: {'request': request, 'billing_address': profile.get_billing_data(), 'shipping_address': profile.get_shipping_data(), }, }, context={'plan': plan, 'cc_data': profile.get_payment_card() if cc_data['number'] else None, 'rental_plans': get_rental_plans_info(request), 'all_plans': all_plans_info, "limited_plans": limited_plans, "unlimited_plans": unlimited_plans, }) return request.rent_wizard