def renew_duration_choice(request): user=request.user try: request.session['mycart'] except KeyError: return HttpResponseRedirect(reverse('manager_panel')) renew_cart = request.session['mycart'] sub = Subscription.objects.get(id=renew_cart.renew_sub) if not sub.user.id == user.id: return HttpResponseRedirect(reverse(front_index)) if request.method == 'POST': form = VerifyInvoiceCheck(request.POST) if form.is_valid(): print "prout" form = VerifyInvoiceCheck() return render_to_response('billing/renew_subscription.html', {'subscription':sub}, context_instance=RequestContext(request))
def verify_invoice(request): user=request.user try: request.session['mycart'] except KeyError: return HttpResponseRedirect(reverse('manager_panel')) selection = request.session['mycart'] offer = Offer.objects.get(id=int(selection.item_id)) quantity = selection.quantity offer_price, quantity, total_wot, vat_rate, vat, total_ti = calculate_billing(user, offer, quantity) if request.method == 'POST': form = VerifyInvoiceCheck(request.POST) if form.is_valid(): invoice = Invoice.objects.generate_invoice(user, vat_rate) subscription = Subscription.objects.create_new_subscription(selection.item_id, user.id) invoice_item = InvoiceItem.objects.create_invoice_item(subscription.id, invoice.id, selection.item_id, quantity) transaction = Transaction.objects.new_transaction(invoice.id, total_ti) del request.session['mycart'] return HttpResponseRedirect(reverse('pay_invoice', args=[invoice.id,])) form = VerifyInvoiceCheck() return render_to_response('billing/verify_invoice.html', { 'offer_price':offer_price, 'quantity':quantity, 'total_wot':total_wot, 'vat_rate':vat_rate, 'vat':vat, 'total_ti':total_ti, 'offer':offer, 'user':user, 'form':form }, context_instance=RequestContext(request))