Esempio n. 1
0
File: views.py Progetto: kmax12/lts
def address(request):
    saved = False

    if request.POST:
        saved = True

        form = AddressForm(request.POST, instance=request.user.address)
        a = form.save(commit=False)
        a.edited = True

        a.save()

        name = request.POST.get('name', '')
        if name != request.user.first_name:
            request.user.first_name = name
            request.user.save()

        
    template_values = {
        'form': AddressForm(instance=request.user.address),
        'name' : request.user.first_name,
        'address_active': "active",
        'saved': saved
    }

    return direct_to_template(request, 'edit_address.html', template_values)
Esempio n. 2
0
File: views.py Progetto: kmax12/lts
def add_address(request):
    address = AddressForm(request.POST)
    address = address.save(commit=False)
    address.owner = request.user
    address.save()
    success = True

    return HttpResponse(json.dumps({'success':success}), mimetype="application/json")