Ejemplo n.º 1
0
def edit_address(request, address_type):

    if address_type not in ADDRESS_TYPES:
        raise Http404

    messages = FlashMessages()
    data = request.POST if request.method == 'POST' else None
    customer = _get_customer(request)
    address = customer.addresses.get(address_type, None)
    form = AddressForm(
        data,
        instance=address)

    if processed:
        address = form.save()
        messages.success(request, _("Your %s address has been "
                                    "updated.") % address_type)
        messages.transmit()

        return redirect(
            reverse(
                request.POST.get(
                    'next',
                    request.GET.get('next', 'account:profile')),
                current_app=resolve(request.path).namespace
            )
        )

    context = {
        'customer': customer,
        'address': address,
        'form': form }

    return TemplateResponse(request, 'account/edit_address.html', context)
Ejemplo n.º 2
0
def edit_profile(request):

    messages = FlashMessages()
    data = request.POST if request.method == 'POST' else None
    customer = _get_customer(request)
    form = CustomerForm(
        data,
        instance=customer)

    processed = data and form.is_valid()
    if processed:
        customer = form.save()
        messages.success(request, _("Your profile has been "
                                    "updated."))

        messages.transmit()

        return redirect(
            reverse(
                request.POST.get(
                    'next',
                    request.GET.get('next', 'account:profile')),
                current_app=resolve(request.path).namespace
            )
        )

    context = {
        'customer': customer,
        'form': form
    }

    return TemplateResponse(request, 'account/edit_profile.html', context)
Ejemplo n.º 3
0
def edit_address(request, address_type):

    if address_type not in ADDRESS_TYPES:
        raise Http404

    messages = FlashMessages()
    data = request.POST if request.method == 'POST' else None
    customer = _get_customer(request)
    address = customer.addresses.get(address_type, None)
    form = AddressForm(data, instance=address)

    if processed:
        address = form.save()
        messages.success(
            request,
            _("Your %s address has been "
              "updated.") % address_type)
        messages.transmit()

        return redirect(
            reverse(request.POST.get(
                'next', request.GET.get('next', 'account:profile')),
                    current_app=resolve(request.path).namespace))

    context = {'customer': customer, 'address': address, 'form': form}

    return TemplateResponse(request, 'account/edit_address.html', context)
Ejemplo n.º 4
0
def edit_profile(request):

    messages = FlashMessages()
    data = request.POST if request.method == 'POST' else None
    customer = _get_customer(request)
    form = CustomerForm(data, instance=customer)

    processed = data and form.is_valid()
    if processed:
        customer = form.save()
        messages.success(request, _("Your profile has been " "updated."))

        messages.transmit()

        return redirect(
            reverse(request.POST.get(
                'next', request.GET.get('next', 'account:profile')),
                    current_app=resolve(request.path).namespace))

    context = {'customer': customer, 'form': form}

    return TemplateResponse(request, 'account/edit_profile.html', context)