コード例 #1
0
def manage_customer_tax(request,
                        id,
                        template_name="manage/customer_tax/customer_tax.html"):
    """Displays the main form to manage customer taxes.
    """
    customer_tax = get_object_or_404(CustomerTax, pk=id)
    if request.method == "POST":
        form = CustomerTaxForm(instance=customer_tax,
                               data=request.POST,
                               files=request.FILES)
        if form.is_valid():
            form.save()
            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_customer_tax",
                            kwargs={"id": customer_tax.id}),
                msg=_(u"Customer tax has been saved."),
            )
    else:
        form = CustomerTaxForm(instance=customer_tax)

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "customer_tax": customer_tax,
                "customer_taxes": CustomerTax.objects.all(),
                "form": form,
                "current_id": int(id),
            }))
コード例 #2
0
ファイル: views.py プロジェクト: zenith0/django-muecke
def add_customer_tax(request, template_name="manage/customer_tax/add_customer_tax.html"):
    """Provides a form to add a new customer tax.
    """
    if request.method == "POST":
        form = CustomerTaxForm(data=request.POST, files=request.FILES)
        if form.is_valid():
            tax = form.save()

            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_customer_tax", kwargs={"id": tax.id}),
                msg=_(u"Customer tax has been added."),
            )
    else:
        form = CustomerTaxForm()

    return render_to_response(template_name, RequestContext(request, {
        "form": form,
        "customer_taxes": CustomerTax.objects.all(),
        "next": request.REQUEST.get("next", request.META.get("HTTP_REFERER")),
    }))
コード例 #3
0
ファイル: views.py プロジェクト: zenith0/django-muecke
def manage_customer_tax(request, id, template_name="manage/customer_tax/customer_tax.html"):
    """Displays the main form to manage customer taxes.
    """
    customer_tax = get_object_or_404(CustomerTax, pk=id)
    if request.method == "POST":
        form = CustomerTaxForm(instance=customer_tax, data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save()
            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_customer_tax", kwargs={"id": customer_tax.id}),
                msg=_(u"Customer tax has been saved."),
            )
    else:
        form = CustomerTaxForm(instance=customer_tax)

    return render_to_response(template_name, RequestContext(request, {
        "customer_tax": customer_tax,
        "customer_taxes": CustomerTax.objects.all(),
        "form": form,
        "current_id": int(id),
    }))
コード例 #4
0
def add_customer_tax(request,
                     template_name="manage/customer_tax/add_customer_tax.html"
                     ):
    """Provides a form to add a new customer tax.
    """
    if request.method == "POST":
        form = CustomerTaxForm(data=request.POST, files=request.FILES)
        if form.is_valid():
            tax = form.save()

            return muecke.core.utils.set_message_cookie(
                url=reverse("muecke_manage_customer_tax",
                            kwargs={"id": tax.id}),
                msg=_(u"Customer tax has been added."),
            )
    else:
        form = CustomerTaxForm()

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "form":
                form,
                "customer_taxes":
                CustomerTax.objects.all(),
                "next":
                request.REQUEST.get("next", request.META.get("HTTP_REFERER")),
            }))