コード例 #1
0
def manage_product(request, product_id, template_name="manage/product/product.html"):
    """
    Displays the whole manage/edit form for the product with the passed id.
    """
    AMOUNT = 20
    product = lfs_get_object_or_404(Product, pk=product_id)
    products = _get_filtered_products_for_product_view(request)
    paginator = Paginator(products, AMOUNT)

    temp = product.parent if product.is_variant() else product
    page = get_current_page(request, products, temp, AMOUNT)

    try:
        page = paginator.page(page)
    except EmptyPage:
        page = paginator.page(1)

    return render_to_response(template_name, RequestContext(request, {
        "product": product,
        "product_filters": product_filters_inline(request, page, paginator, product_id),
        "pages_inline": pages_inline(request, page, paginator, product_id),
        "product_data": product_data_form(request, product_id),
        "images": manage_images(request, product_id, as_string=True),
        "attachments": manage_attachments(request, product_id, as_string=True),
        "selectable_products": selectable_products_inline(request, page, paginator, product.id),
        "seo": manage_seo(request, product_id),
        "stock": stock(request, product_id),
        "portlets": portlets_inline(request, product),
        "properties": manage_properties(request, product_id),
        "form": ProductSubTypeForm(instance=product),
        "name_filter_value": request.session.get("product_filters", {}).get("product_name", ""),
    }))
コード例 #2
0
ファイル: product.py プロジェクト: potar/lfs
def manage_product(request, product_id, template_name="manage/product/product.html"):
    """Displays the whole manage/edit form for the product with the passed id.
    """
    # NOTE: For any reason the script from swfupload (see product/images.html)
    # calls this method (I have no idea how and why). It calls it without a 
    # product id so we have to take care of it here as a workaround.
    if not product_id:
        return HttpResponse("")

    product = lfs_get_object_or_404(Product, pk=product_id)
    products = _get_filtered_products(request)
    paginator = Paginator(products, 20)
    page = paginator.page(request.REQUEST.get("page", 1))

    try:
        product = Product.objects.get(pk=product_id)
    except Exception:
        return HttpResponse("")

    return render_to_response(template_name, RequestContext(request, {
        "product" : product,
        "product_filters" : product_filters_inline(request, page, paginator, product_id),
        "pages_inline" : pages_inline(request, page, paginator),
        "product_data" : product_data_form(request, product_id),
        "images" : manage_images(request, product_id, as_string=True),
        "selectable_products" : selectable_products_inline(request, page, paginator, product.id),
        "seo" : manage_seo(request, product_id),
        "stock" : stock(request, product_id),
        "portlets" : portlets_inline(request, product),
        "properties" : manage_properties(request, product_id),
        "form" : ProductSubTypeForm(instance=product)
    }))