Beispiel #1
0
def edit_address(request, address_id):
    c = shortcuts.get_object_or_404(ContactAddress, id=address_id, user=request.user)
    if request.POST:
        form = ContactAddressForm(request.POST, instance=c)
        if form.is_valid():
            addr = form.save(request.user)
            if addr.is_default:
                setdefault_address(request, addr.id)
            messages.success(request, u'送货地址更改成功。')
            return shortcuts.redirect(reverse('account-address-list'))
    else:
        form = ContactAddressForm(instance=c)
    return shortcuts.render_to_response('account/address.html',
                                        {'form': form},
                                        context_instance=RequestContext(request))
Beispiel #2
0
def add_address(request):
    if request.POST:
        form = ContactAddressForm(request.POST)
        if form.is_valid():
            addr = form.save(request.user)
            
            if addr.is_default:
                setdefault_address(request, addr.id)
                
            messages.success(request, u'新的送货地址保存成功。')
            return shortcuts.redirect(reverse('account-address-list')) 
    else:
        form = ContactAddressForm()
        
    return shortcuts.render_to_response('account/address.html',
                                        {'form': form},
                                        context_instance=RequestContext(request))
Beispiel #3
0
def edit_address(request, address_id):
    c = shortcuts.get_object_or_404(ContactAddress, id=address_id, user=request.user)
    if request.POST:
        form = ContactAddressForm(request.POST, instance=c)
        if form.is_valid():
            addr = form.save(request.user)
            if addr.is_default:
                setdefault_address(request, addr.id)
            messages.success(request, u'送货地址更改成功。')
            return shortcuts.redirect(reverse('account-home'))
    else:
        form = ContactAddressForm(instance=c)
    return shortcuts.render_to_response('account/address.html',
                                        {'form': form},
                                        context_instance=RequestContext(request))
Beispiel #4
0
def add_address(request):
    if request.POST:
        form = ContactAddressForm(request.POST)
        if form.is_valid():
            addr = form.save(request.user)
            
            if addr.is_default:
                setdefault_address(request, addr.id)
                
            messages.success(request, u'新的送货地址保存成功。')
            return shortcuts.redirect(reverse('account-home')) 
    else:
        form = ContactAddressForm()
        
    return shortcuts.render_to_response('account/address.html',
                                        {'form': form},
                                        context_instance=RequestContext(request))