def addNewFund(request): mlogger.debug("adding new fund") if request.method == "GET": form = FundForm() return render_to_response('payments/addfund.html',{'form':form},RequestContext(request)) elif request.method == "POST": form = FundForm(request.POST) if form.is_valid() : fund = form.save(commit=False) fund.institute = request.institute fund.user = request.user fund.save() create_message(request,"Created new fund successfully...............") return HttpResponseRedirect(reverse('displayfundsurl')) else : return render_to_response('payments/addfund.html',{'form':form},RequestContext(request))
def editFund(request, fundid): fundid = int(fundid) fund = Fund.objects.get(pk=fundid) if request.user.id == fund.user.id: if request.method == "GET": mlogger.debug("the person who posted the fund is editing") form = FundForm(instance=fund) return render_to_response('payments/addfund.html', { 'form': form, 'editmode': True }, RequestContext(request)) elif request.method == "POST": form = FundForm(request.POST, instance=fund) if form.is_valid(): form.save() create_message(request, "Successfuly edited the fund") return HttpResponseRedirect(reverse('displayfundsurl')) else: return render_to_response('payments/addfund.html', { 'form': form, 'editmode': True }, RequestContext(request)) else: create_message(request, "You are not authorized to edit this fund") return HttpResponseRedirect(reverse('displayfundsurl'))
def editFund(request,fundid): fundid = int(fundid) fund = Fund.objects.get(pk=fundid) if request.user.id == fund.user.id : if request.method == "GET" : mlogger.debug("the person who posted the fund is editing") form = FundForm(instance=fund) return render_to_response('payments/addfund.html',{'form':form,'editmode':True},RequestContext(request)) elif request.method == "POST": form = FundForm(request.POST, instance=fund) if form.is_valid() : form.save() create_message(request,"Successfuly edited the fund") return HttpResponseRedirect(reverse('displayfundsurl')) else: return render_to_response('payments/addfund.html',{'form':form,'editmode':True},RequestContext(request)) else : create_message(request,"You are not authorized to edit this fund") return HttpResponseRedirect(reverse('displayfundsurl'))
def addNewFund(request): mlogger.debug("adding new fund") if request.method == "GET": form = FundForm() return render_to_response('payments/addfund.html', {'form': form}, RequestContext(request)) elif request.method == "POST": form = FundForm(request.POST) if form.is_valid(): fund = form.save(commit=False) fund.institute = request.institute fund.user = request.user fund.save() create_message(request, "Created new fund successfully...............") return HttpResponseRedirect(reverse('displayfundsurl')) else: return render_to_response('payments/addfund.html', {'form': form}, RequestContext(request))