from django.shortcuts import render_to_response from django.template import RequestContext from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect from models import Transaction, TransactionType from forms import TransactionForm import datetime @login_required def overview(request): history = Transaction.objects.filter(user=request.user).order_by("-dateTime") transacted = False error = False if request.method == 'POST': transacted = True transaction = Transaction(user=request.user, dateTime=datetime.datetime.now()) form = TransactionForm(request.POST, instance=transaction) if form.is_valid(): form.save() form = TransactionForm() transacted = True else: error = True form = TransactionForm() else: form = TransactionForm() return render_to_response("transaction/overview.html", {'history': history, 'form': form, 'transacted': transacted, 'error': error}, RequestContext(request)) @login_required def transact(request): if request.method == 'POST': return render_to_response("transaction/transfered.html", RequestContext(request)) else: return HttpResponseRedirect("/transaction/") #@kassenwart_required #def checkTransfers(request): # transfers = Transaction.objects.filter(checked=False).order_by("dateTime") # return render_to_response("transaction/uncheckedTransfers.html", {'transfers' : tranfers}, RequestContext(request))