|
|
|
@ -23,12 +23,15 @@ def overview(request):
|
|
|
|
|
# create forms
|
|
|
|
|
form = TransactionForm()
|
|
|
|
|
vform = VirtualTransactionForm()
|
|
|
|
|
state = None
|
|
|
|
|
state =None
|
|
|
|
|
payway = "payin"
|
|
|
|
|
if request.method == 'POST' and request.POST.has_key('_formtype'):
|
|
|
|
|
if request.POST['_formtype'] == "normal":
|
|
|
|
|
transaction = Transaction(user=request.user)
|
|
|
|
|
form = TransactionForm(request.POST, instance=transaction)
|
|
|
|
|
if form.is_valid():
|
|
|
|
|
if form.cleaned_data['amount'] < 0:
|
|
|
|
|
payway = "payout"
|
|
|
|
|
form.save()
|
|
|
|
|
form = TransactionForm()
|
|
|
|
|
state = "success"
|
|
|
|
@ -44,12 +47,12 @@ def overview(request):
|
|
|
|
|
state = "vsuccess"
|
|
|
|
|
else:
|
|
|
|
|
state = "verror"
|
|
|
|
|
return HttpResponseRedirect("state/%s/" % state)
|
|
|
|
|
return render_to_response("transaction/overview.html", {'history': history, 'vhistory': vhistory, 'form': form, 'transacted': False, 'error': False, 'vform': vform, 'vtransacted': False, 'verror': False}, RequestContext(request))
|
|
|
|
|
return HttpResponseRedirect("state/%s/%s/" % (state,payway))
|
|
|
|
|
return render_to_response("transaction/overview.html", {'history': history, 'vhistory': vhistory, 'form': form, 'transacted': False, 'payout': payout, 'error': False, 'vform': vform, 'vtransacted': False, 'verror': False}, RequestContext(request))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def state(request, state=""):
|
|
|
|
|
def state(request, state="", payway=""):
|
|
|
|
|
""" View which shows the state/return-msg of a transaction."""
|
|
|
|
|
# create history
|
|
|
|
|
history = Transaction.objects.filter(user=request.user).order_by("-dateTime")
|
|
|
|
@ -60,6 +63,7 @@ def state(request, state=""):
|
|
|
|
|
|
|
|
|
|
error = verror = False
|
|
|
|
|
transacted = vtransacted = False
|
|
|
|
|
payout = False
|
|
|
|
|
if state == "" or state == "error":
|
|
|
|
|
error = True
|
|
|
|
|
elif state == "success":
|
|
|
|
@ -68,4 +72,7 @@ def state(request, state=""):
|
|
|
|
|
verror = true
|
|
|
|
|
elif state == "vsuccess":
|
|
|
|
|
vtransacted = True
|
|
|
|
|
return render_to_response("transaction/overview.html", {'history': history, 'vhistory': vhistory, 'form': form, 'transacted': transacted, 'error': error, 'vform': vform, 'vtransacted': vtransacted, 'verror': verror}, RequestContext(request))
|
|
|
|
|
|
|
|
|
|
if payway == "payout":
|
|
|
|
|
payout = True
|
|
|
|
|
return render_to_response("transaction/overview.html", {'history': history, 'vhistory': vhistory, 'form': form, 'transacted': transacted, 'payout': payout, 'error': error, 'vform': vform, 'vtransacted': vtransacted, 'verror': verror}, RequestContext(request))
|
|
|
|
|