*fix: Ticket #88 (use RPG for transactions)
This commit is contained in:
parent
3df2c2e122
commit
4317bde253
|
@ -10,7 +10,5 @@ from django.conf.urls.defaults import *
|
|||
|
||||
urlpatterns = patterns('',
|
||||
(r'^$', 'transaction.views.overview'),
|
||||
#(r'^transact/$', 'transaction.views.transact'),
|
||||
#(r'^transfer/$', 'transaction.views.transfer'),
|
||||
#(r'^checkTransfers/$', 'transaction.views.checkTransfers'),
|
||||
url(r'^state/(success|error|vsuccess|verror)/$', 'transaction.views.state'),
|
||||
)
|
||||
|
|
|
@ -23,29 +23,49 @@ def overview(request):
|
|||
# create forms
|
||||
form = TransactionForm()
|
||||
vform = VirtualTransactionForm()
|
||||
transacted = vtransacted = False
|
||||
error = verror = False
|
||||
state = None
|
||||
if request.method == 'POST' and request.POST.has_key('_formtype'):
|
||||
if request.POST['_formtype'] == "normal":
|
||||
transacted = True
|
||||
transaction = Transaction(user=request.user)
|
||||
form = TransactionForm(request.POST, instance=transaction)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
form = TransactionForm()
|
||||
transacted = True
|
||||
state = "success"
|
||||
else:
|
||||
error = True
|
||||
state = "error"
|
||||
form = TransactionForm()
|
||||
elif request.POST['_formtype'] == "virtual":
|
||||
vtransacted = True
|
||||
vtransaction = VirtualTransaction(user=request.user)
|
||||
vform = VirtualTransactionForm(request.POST, instance=vtransaction)
|
||||
if vform.is_valid():
|
||||
vform.save()
|
||||
vform = VirtualTransactionForm()
|
||||
vtransacted = True
|
||||
state = "vsuccess"
|
||||
else:
|
||||
error = 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))
|
||||
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
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue