예제 #1
0
파일: views.py 프로젝트: kayethano/howmuch
def edit_address(request, addressID):
    current = get_object_or_404(Address, pk=addressID, owner = request.user)

    if request.method == 'POST':
        form = AddressForm(request.POST, instance=current)
        if form.is_valid():
            address = form.save()
            return HttpResponseRedirect('/profile/e/edit')
    else:
        form = AddressForm(instance=current)
    return render_to_response('profile/newAddress.html', {'form':form},
        context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: kayethano/howmuch
def new_address(request):
    if request.method == 'POST':
        form = AddressForm(request.POST)
        if form.is_valid():
            newAddress = form.save(commit=False)
            newAddress.owner = request.user
            newAddress.save()
            request.user.profile.addresses.add(newAddress)
            return HttpResponseRedirect('/profile/e/edit')
    else:
        form = AddressForm()
    return render_to_response('profile/newAddress.html', {'form' : form}, 
        context_instance=RequestContext(request))
예제 #3
0
파일: views.py 프로젝트: kahihia/howmuch
def edit_address(request, addressID):
    current = get_object_or_404(Address, pk=addressID, owner=request.user)

    if request.method == 'POST':
        form = AddressForm(request.POST, instance=current)
        if form.is_valid():
            address = form.save()
            return HttpResponseRedirect('/profile/e/edit')
    else:
        form = AddressForm(instance=current)
    return render_to_response('profile/newAddress.html', {'form': form},
                              context_instance=RequestContext(request))
예제 #4
0
파일: views.py 프로젝트: kahihia/howmuch
def new_address(request):
    if request.method == 'POST':
        form = AddressForm(request.POST)
        if form.is_valid():
            newAddress = form.save(commit=False)
            newAddress.owner = request.user
            newAddress.save()
            request.user.profile.addresses.add(newAddress)
            return HttpResponseRedirect('/profile/e/edit')
    else:
        form = AddressForm()
    return render_to_response('profile/newAddress.html', {'form': form},
                              context_instance=RequestContext(request))