Example #1
0
File: views.py Project: CS2014/USM
def transaction_edit(request, id):
	instance = get_object_or_404(Transaction, id=id)
	form = TransactionForm(request.POST or none, instance=instance)
	if form.is_valid():
		form.save()
		return HttpResponseRedirect('/accounting/transactions')
	object = TransactionForm(data=model_to_dict(instance))
	return render(request, 'transactions/detail.html', {'object':object})       
Example #2
0
File: views.py Project: CS2014/USM
def transactions(request, slug):
		society = get_object_or_404(Society, slug=slug)
		try:
			society.members.get(pk=request.user.id)
		except society.DoesNotExist:
			return HttpResponseRedirect('/')

		account = society.account
		transactions = get_transactions(request,account)
		categories = account.transactioncategory_set.all()

		if request.method == 'POST':
				form = TransactionForm(request.POST)
				if form.is_valid():
					form.save()
				else:
					print form.errors
				return redirect('/'+slug+'/transactions')
		transaction_form = TransactionForm(initial={'account': account})
		return render(request, 'accounting/transactions.html', {'account' : account, 
			'transactions':transactions,'transaction_form' : transaction_form,'society': society, "categories":categories})