Example #1
0
def manage_shop(request, template_name="manage/shop/shop.html"):
    """Displays the form to manage shop data.
    """
    shop = lfs.core.utils.get_default_shop()
    data_form = ShopDataForm(instance=shop)
    default_values_form = ShopDefaultValuesForm(instance=shop)

    ong = lfs.core.utils.import_symbol(settings.LFS_ORDER_NUMBER_GENERATOR)

    try:
        order_number = ong.objects.get(id="order_number")
    except ong.DoesNotExist:
        order_number = ong.objects.create(id="order_number")
    order_numbers_form = order_number.get_form(instance=order_number)

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "shop":
                shop,
                "data":
                data_tab(request, shop, data_form),
                "default_values":
                default_values_tab(request, shop, default_values_form),
                "order_numbers":
                order_numbers_tab(request, shop, order_numbers_form),
                "seo":
                ShopSEOView(Shop).render(request, shop),
                "portlets":
                portlets_inline(request, shop),
            }))
Example #2
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", ""),
    }))
Example #3
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.
    """
    product = lfs_get_object_or_404(Product, pk=product_id)
    products = _get_filtered_products_for_product_view(request)
    paginator = Paginator(products, 25)
    temp = product.parent if product.is_variant() else product
    page = get_current_page(request, products, temp, 25)

    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": SEOView(Product, form_klass=SEOForm, template_name='manage/product/seo.html').render(request, product),
        "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", ""),
    }))
Example #4
0
def manage_shop(request, template_name="manage/shop/shop.html"):
    """Displays the form to manage shop data.
    """
    shop = lfs.core.utils.get_default_shop()
    data_form = ShopDataForm(instance=shop)
    default_values_form = ShopDefaultValuesForm(instance=shop)

    ong = lfs.core.utils.import_symbol(settings.LFS_ORDER_NUMBER_GENERATOR)

    try:
        order_number = ong.objects.get(id="order_number")
    except ong.DoesNotExist:
        order_number = ong.objects.create(id="order_number")
    order_numbers_form = order_number.get_form(instance=order_number)

    return render_to_response(
        template_name,
        RequestContext(
            request,
            {
                "shop": shop,
                "data": data_tab(request, shop, data_form),
                "default_values": default_values_tab(request, shop, default_values_form),
                "order_numbers": order_numbers_tab(request, shop, order_numbers_form),
                "seo": ShopSEOView(Shop).render(request, shop),
                "portlets": portlets_inline(request, shop),
            },
        ),
    )
Example #5
0
def manage_category(request,
                    category_id,
                    template_name="manage/category/manage_category.html"):
    """Displays the form to manage the category with given category id.
    """
    category = Category.objects.get(pk=category_id)

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "categories_portlet":
                manage_categories_portlet(request, category_id),
                "category":
                category,
                "data":
                category_data(request, category_id),
                "seo":
                SEOView(Category).render(request, category),
                "view":
                category_view(request, category_id),
                "portlets":
                portlets_inline(request, category),
                "dialog_message":
                _("Do you really want to delete the category <b>'%(name)s'</b> and all its sub categories?"
                  ) % {
                      "name": category.name
                  },
            }))
Example #6
0
File: product.py Project: 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)
    }))
Example #7
0
def manage_page(request, id, template_name="manage/pages/page.html"):
    """Provides a form to edit the page with the passed id.
    """
    page = get_object_or_404(Page, pk=id)

    return render(request, template_name, {
        "page": page,
        "navigation": navigation(request, page),
        "seo_tab": PageSEOView(Page).render(request, page),
        "data_tab": data_tab(request, page),
        "portlets": portlets_inline(request, page),
    })
Example #8
0
def manage_page(request, id, template_name="manage/pages/page.html"):
    """Provides a form to edit the page with the passed id.
    """
    page = get_object_or_404(Page, pk=id)

    return render_to_response(template_name, RequestContext(request, {
        "page": page,
        "navigation": navigation(request, page),
        "seo_tab": PageSEOView(Page).render(request, page),
        "data_tab": data_tab(request, page),
        "portlets": portlets_inline(request, page),
    }))
Example #9
0
def manage_category(request, category_id, template_name="manage/category/manage_category.html"):
    """Displays the form to manage the category with given category id.
    """
    category = Category.objects.get(pk=category_id)

    return render_to_response(template_name, RequestContext(request, {
        "categories_portlet" : manage_categories_portlet(request, category_id),
        "category" : category,
        # "products" : manage_products(request, category.id),
        "data" : category_data(request, category_id),
        "seo" : edit_seo(request, category_id),
        "portlets" : portlets_inline(request, category),
    }))
Example #10
0
def manage_category(request, category_id, template_name="manage/category/manage_category.html"):
    """Displays the form to manage the category with given category id.
    """
    category = Category.objects.get(pk=category_id)

    return render_to_response(template_name, RequestContext(request, {
        "categories_portlet": manage_categories_portlet(request, category_id),
        "category": category,
        "data": category_data(request, category_id),
        "seo": edit_seo(request, category_id),
        "view": category_view(request, category_id),
        "portlets": portlets_inline(request, category),
        "dialog_message": _("Do you really want to delete the category <b>'%(name)s'</b> and all its sub categories?" % {"name": category.name}),
    }))
Example #11
0
def manage_page(request, id, template_name="manage/page/page.html"):
    """Provides a form to edit the page with the passed id.
    """
    page = get_object_or_404(Page, pk=id)

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "page": page,
                "navigation": navigation(request, page),
                "seo_tab": seo_tab(request, page),
                "data_tab": data_tab(request, page),
                "portlets": portlets_inline(request, page),
            }))
Example #12
0
def manage_shop(request, template_name="manage/shop/shop.html"):
    """Displays the form to manage shop data.
    """
    shop = lfs.core.utils.get_default_shop()
    data_form = ShopDataForm(instance=shop)
    seo_form = ShopSEOForm(instance=shop)
    default_values_form = ShopDefaultValuesForm(instance=shop)

    try:
        order_number = MODELS.OrderNumberGenerator.objects.get(id="order_number")
    except MODELS.OrderNumberGenerator.DoesNotExist:
        order_number = MODELS.OrderNumberGenerator.objects.create(id="order_number")
    order_numbers_form = FORMS.OrderNumberGeneratorForm(instance=order_number)

    return render_to_response(template_name, RequestContext(request, {
        "shop": shop,
        "data": data_tab(request, shop, data_form),
        "default_values": default_values_tab(request, shop, default_values_form),
        "order_numbers": order_numbers_tab(request, shop, order_numbers_form),
        "seo": seo_tab(request, shop, seo_form),
        "portlets": portlets_inline(request, shop),
    }))
Example #13
0
def manage_shop(request, template_name="manage/shop/shop.html"):
    """Displays the form to manage shop data.
    """
    shop = lfs_get_object_or_404(Shop, pk=1)
    if request.method == "POST":
        form = ShopForm(instance=shop, data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save()
            return lfs.core.utils.set_message_cookie(
                url=reverse("lfs_manage_shop"),
                msg=_(u"Shop data has been saved."),
            )
    else:
        form = ShopForm(instance=shop)

    return render_to_response(
        template_name,
        RequestContext(
            request, {
                "shop": shop,
                "form": form,
                "default_values": default_values_part(request),
                "portlets": portlets_inline(request, shop),
            }))
Example #14
0
def manage_category(request,
                    category_id,
                    template_name="manage/category/manage_category.html"):
    """Displays the form to manage the category with given category id.
    """
    category = Category.objects.get(pk=category_id)

    return render_to_response(
        template_name,
        RequestContext(
            request,
            {
                "categories_portlet":
                manage_categories_portlet(request, category_id),
                "category":
                category,
                # "products" : manage_products(request, category.id),
                "data":
                category_data(request, category_id),
                "seo":
                edit_seo(request, category_id),
                "portlets":
                portlets_inline(request, category),
            }))