|
|
@ -23,29 +23,49 @@ def overview(request):
|
|
|
|
# create forms
|
|
|
|
# create forms
|
|
|
|
form = TransactionForm()
|
|
|
|
form = TransactionForm()
|
|
|
|
vform = VirtualTransactionForm()
|
|
|
|
vform = VirtualTransactionForm()
|
|
|
|
transacted = vtransacted = False
|
|
|
|
state = None
|
|
|
|
error = verror = False
|
|
|
|
|
|
|
|
if request.method == 'POST' and request.POST.has_key('_formtype'):
|
|
|
|
if request.method == 'POST' and request.POST.has_key('_formtype'):
|
|
|
|
if request.POST['_formtype'] == "normal":
|
|
|
|
if request.POST['_formtype'] == "normal":
|
|
|
|
transacted = True
|
|
|
|
|
|
|
|
transaction = Transaction(user=request.user)
|
|
|
|
transaction = Transaction(user=request.user)
|
|
|
|
form = TransactionForm(request.POST, instance=transaction)
|
|
|
|
form = TransactionForm(request.POST, instance=transaction)
|
|
|
|
if form.is_valid():
|
|
|
|
if form.is_valid():
|
|
|
|
form.save()
|
|
|
|
form.save()
|
|
|
|
form = TransactionForm()
|
|
|
|
form = TransactionForm()
|
|
|
|
transacted = True
|
|
|
|
state = "success"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
error = True
|
|
|
|
state = "error"
|
|
|
|
form = TransactionForm()
|
|
|
|
form = TransactionForm()
|
|
|
|
elif request.POST['_formtype'] == "virtual":
|
|
|
|
elif request.POST['_formtype'] == "virtual":
|
|
|
|
vtransacted = True
|
|
|
|
|
|
|
|
vtransaction = VirtualTransaction(user=request.user)
|
|
|
|
vtransaction = VirtualTransaction(user=request.user)
|
|
|
|
vform = VirtualTransactionForm(request.POST, instance=vtransaction)
|
|
|
|
vform = VirtualTransactionForm(request.POST, instance=vtransaction)
|
|
|
|
if vform.is_valid():
|
|
|
|
if vform.is_valid():
|
|
|
|
vform.save()
|
|
|
|
vform.save()
|
|
|
|
vform = VirtualTransactionForm()
|
|
|
|
vform = VirtualTransactionForm()
|
|
|
|
vtransacted = True
|
|
|
|
state = "vsuccess"
|
|
|
|
else:
|
|
|
|
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))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
|
|
|
def state(request, state=""):
|
|
|
|
|
|
|
|
""" View which shows the state/return-msg of a transaction."""
|
|
|
|
|
|
|
|
# create history
|
|
|
|
|
|
|
|
history = Transaction.objects.filter(user=request.user).order_by("-dateTime")
|
|
|
|
|
|
|
|
vhistory = VirtualTransaction.objects.filter(Q(user=request.user) | Q(recipient=request.user)).order_by("-dateTime")
|
|
|
|
|
|
|
|
# create forms
|
|
|
|
|
|
|
|
form = TransactionForm()
|
|
|
|
|
|
|
|
vform = VirtualTransactionForm()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = verror = False
|
|
|
|
|
|
|
|
transacted = vtransacted = False
|
|
|
|
|
|
|
|
if state == "" or state == "error":
|
|
|
|
error = True
|
|
|
|
error = True
|
|
|
|
|
|
|
|
elif state == "success":
|
|
|
|
|
|
|
|
transacted = True
|
|
|
|
|
|
|
|
elif state == "verror":
|
|
|
|
|
|
|
|
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))
|
|
|
|
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))
|
|
|
|
|
|
|
|
|
|
|
|