コード例 #1
0
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))
コード例 #2
0
ファイル: views.py プロジェクト: ramavadakattu/Groupalumini
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'))
コード例 #3
0
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'))
コード例 #4
0
ファイル: views.py プロジェクト: ramavadakattu/Groupalumini
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))