Esempio n. 1
0
def selectable_customers_inline(
        request,
        customer_id,
        template_name="manage/customer/selectable_customers_inline.html"):
    """Display selectable customers.
    """
    AMOUNT = 30
    customer = lfs_get_object_or_404(Customer, pk=customer_id)
    customer_filters = request.session.get("customer-filters", {})
    customers = _get_filtered_customers(request, customer_filters)

    page = get_current_page(request, customers, customer, AMOUNT)
    paginator = Paginator(customers, AMOUNT)

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

    return render_to_string(
        template_name,
        RequestContext(
            request, {
                "paginator": paginator,
                "page": page,
                "customer_id": int(customer_id),
            }))
Esempio n. 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.
    """
    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", ""),
    }))
Esempio n. 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.
    """
    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", ""),
    }))
Esempio n. 4
0
def selectable_customers_inline(request, customer_id, template_name="manage/customer/selectable_customers_inline.html"):
    """Display selectable customers.
    """
    AMOUNT = 30
    customer = lfs_get_object_or_404(Customer, pk=customer_id)
    customer_filters = request.session.get("customer-filters", {})
    customers = _get_filtered_customers(request, customer_filters)

    # Display only customers with at least one order
    temp = []
    for c in customers:
        orders = Order.objects.filter(session=c.session)
        if (c.user) or (len(orders) > 0):
            temp.append(c)

    page = get_current_page(request, temp, customer, AMOUNT)
    paginator = Paginator(temp, AMOUNT)

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

    return render_to_string(template_name, RequestContext(request, {
        "paginator": paginator,
        "page": page,
        "customer_id": int(customer_id),
    }))
Esempio n. 5
0
def manage_property(request, id, template_name="manage/properties/property.html"):
    """The main view to manage the property with passed id.
    """
    prop = get_object_or_404(Property, pk=id)
    if request.method == "POST":
        form = PropertyDataForm(instance=prop, data=request.POST)
        if form.is_valid():
            form.save()
            _update_property_positions()
            return lfs.core.utils.set_message_cookie(
                url=reverse("lfs_manage_shop_property", kwargs={"id": prop.id}),
                msg=_(u"Property type has been saved."),
            )

    else:
        form = PropertyDataForm(instance=prop)

    display_step_form = prop.is_number_field and prop.filterable

    # return render_to_response(template_name, RequestContext(request, {
    #     "property": prop,
    #     "properties": Property.objects.filter(local=False),
    #     "form": form,
    #     "type_form": PropertyTypeForm(instance=prop),
    #     "current_id": int(id),
    #     "options": options_inline(request, id),
    #     "steps": steps_inline(request, id),
    #     "number_field": number_field(request, prop),
    #     "select_field": select_field(request, prop),
    #     "display_step_form": display_step_form,
    #   }))

    properties = _get_filtered_properties_for_property_view(request)
    paginator = Paginator(properties, 25)
    page = get_current_page(request, properties, prop, 25)

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

    return render_to_response(template_name, RequestContext(request, {
        "property": prop,
        "form": form,
        "type_form": PropertyTypeForm(instance=prop),
        "current_id": int(id),
        "options": options_inline(request, id),
        "steps": steps_inline(request, id),
        "number_field": number_field(request, prop),
        "select_field": select_field(request, prop),
        "display_step_form": display_step_form,

        "selectable_properties": selectable_properties_inline(request, page, paginator, id),
        # pagination data:
        "properties": properties,
        "pages_inline": pages_inline(request, page, paginator, id),
        "name_filter_value": request.session.get("property_filters", {}).get("property_name", ""),
    }))
Esempio n. 6
0
def manage_property(request, id, template_name="manage/properties/property.html"):
    """The main view to manage the property with passed id.
    """
    prop = get_object_or_404(Property, pk=id)
    if request.method == "POST":
        form = PropertyDataForm(instance=prop, data=request.POST)
        if form.is_valid():
            form.save()
            _update_property_positions()
            return lfs.core.utils.set_message_cookie(
                url=reverse("lfs_manage_shop_property", kwargs={"id": prop.id}),
                msg=_(u"Property type has been saved."),
            )

    else:
        form = PropertyDataForm(instance=prop)

    display_step_form = prop.is_number_field and prop.filterable

    # return render_to_response(template_name, RequestContext(request, {
    #     "property": prop,
    #     "properties": Property.objects.filter(local=False),
    #     "form": form,
    #     "type_form": PropertyTypeForm(instance=prop),
    #     "current_id": int(id),
    #     "options": options_inline(request, id),
    #     "steps": steps_inline(request, id),
    #     "number_field": number_field(request, prop),
    #     "select_field": select_field(request, prop),
    #     "display_step_form": display_step_form,
    #   }))

    properties = _get_filtered_properties_for_property_view(request)
    paginator = Paginator(properties, 25)
    page = get_current_page(request, properties, prop, 25)

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

    return render_to_response(template_name, RequestContext(request, {
        "property": prop,
        "form": form,
        "type_form": PropertyTypeForm(instance=prop),
        "current_id": int(id),
        "options": options_inline(request, id),
        "steps": steps_inline(request, id),
        "number_field": number_field(request, prop),
        "select_field": select_field(request, prop),
        "display_step_form": display_step_form,

        "selectable_properties": selectable_properties_inline(request, page, paginator, id),
        # pagination data:
        "properties": properties,
        "pages_inline": pages_inline(request, page, paginator, id),
        "name_filter_value": request.session.get("property_filters", {}).get("property_name", ""),
    }))
Esempio n. 7
0
def selectable_customers_inline(request, customer_id, template_name="manage/customer/selectable_customers_inline.html"):
    """Display selectable customers.
    """
    AMOUNT = 30
    customer = lfs_get_object_or_404(Customer, pk=customer_id)
    customer_filters = request.session.get("customer-filters", {})
    customers = _get_filtered_customers(request, customer_filters)

    page = get_current_page(request, customers, customer, AMOUNT)
    paginator = Paginator(customers, AMOUNT)

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

    return render_to_string(
        template_name, RequestContext(request, {"paginator": paginator, "page": page, "customer_id": int(customer_id)})
    )