コード例 #1
0
ファイル: views.py プロジェクト: chrisblythe812/gamemine
def account_terms_and_details(request):
    plan = MemberRentalPlan.get_current_plan(request.user)

    if not plan or plan.status in [RentalPlanStatus.CanceledP, RentalPlanStatus.Collection]:
        return redirect('members:rent_list')

    allowed_games = '2' if plan.plan == RentalPlan.PlanA else 'unlimited'
    price_first_month, price_thereafter_months = RentalPlan.get_prices(plan.plan)
    return {
        'plan': plan,
        'plan_regular': plan.plan == RentalPlan.PlanA or plan.plan == RentalPlan.PlanB or plan.plan == RentalPlan.PlanC,
        'allowed_games': allowed_games,
        'price_first_month': price_first_month,
        'price_thereafter_months': price_thereafter_months,
        'membership_terms': RentalPlan.get_membership_terms(plan.plan) if plan else None,
    }
コード例 #2
0
ファイル: views.py プロジェクト: chrisblythe812/gamemine
def account_billing_history(request):
    history = {}
    qs = BillingHistory.objects.filter(user=request.user,
                                       status__in=[TransactionStatus.Passed],
                                       type__in=[TransactionType.RentPayment, TransactionType.BuyCheckout])
    years = [y.year for y in qs.dates('timestamp', 'year')]
    years.sort()
    months = [m for m in qs.dates('timestamp', 'month')]
    months.sort()
    for m in months:
        history[m] = qs.filter(timestamp__year=m.year, timestamp__month=m.month)

    plan = MemberRentalPlan.get_current_plan(request.user)

    return {
        'title': 'Billing History',
        'price': RentalPlan.get_price_display(plan.plan) if plan else None,
        'membership_terms': RentalPlan.get_membership_terms(plan.plan) if plan else None,
        'years': years,
        'months': months,
        'history': history,
    }