shuup.front.utils package¶
Submodules¶
shuup.front.utils.cache module¶
-
shuup.front.utils.cache.
get_listed_products_cache_item
(shop: typing.Union[shuup.core.models.Shop, int])[source]¶
-
shuup.front.utils.cache.
get_best_selling_products_cache_item
(shop: typing.Union[shuup.core.models.Shop, int])[source]¶
-
shuup.front.utils.cache.
get_newest_products_cache_item
(shop: typing.Union[shuup.core.models.Shop, int])[source]¶
-
shuup.front.utils.cache.
get_random_products_cache_item
(shop: typing.Union[shuup.core.models.Shop, int])[source]¶
-
shuup.front.utils.cache.
get_products_for_category_cache_item
(shop: typing.Union[shuup.core.models.Shop, int])[source]¶
shuup.front.utils.companies module¶
shuup.front.utils.dashboard module¶
-
class
shuup.front.utils.dashboard.
DashboardItemSize
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
SMALL
= 6¶
-
MEDIUM
= 9¶
-
LARGE
= 12¶
-
-
class
shuup.front.utils.dashboard.
DashboardItem
(request)[source]¶ Bases:
object
-
template_name
= 'shuup/front/dashboard/dashboard_base.jinja'¶ Title shown in dashboard menu and in dashboard
-
title
= 'Dashboard'¶ Sequence number of dashboard item
-
ordering
= 0¶ The size of dashboard item block
-
size
= 12¶ Icon shown in menu and dashboard
-
icon
= 'fa fa-tachometer'¶ Text for dashboard
If your dashboard item shows single object,
Edit
is just fine but if you are listing objects,Show All
might be better.
-
view_text
= 'Edit'¶
-
request
= None¶
-
url
¶
-
get_context
()[source]¶ Get context for template
This is usually overridden in subclasses.
Returns: Dict of context items Return type: dict
-
css_class
¶
Defines if the item is shown in the main dashboard menu
Returns: True or False if item should be shown in menu Return type: bool
-
shuup.front.utils.order_source module¶
-
class
shuup.front.utils.order_source.
LineProperty
(name, value)[source]¶ Bases:
object
-
name
= None¶
-
value
= None¶
-
shuup.front.utils.product module¶
-
shuup.front.utils.product.
get_product_context
(request, product, language=None, supplier=None)[source]¶
-
shuup.front.utils.product.
get_default_product_context
(request, product, language=None, supplier=None)[source]¶ Get product context.
Used in
shuup.front.views.product:ProductDetailView
.Returns: A context dict containing everything needed to render product view. Return type: dict
-
shuup.front.utils.product.
get_orderable_variation_children
(product, request, variation_variables, supplier=None)[source]¶
-
class
shuup.front.utils.product.
ProductContextExtra
(request, product, language, **kwargs)[source]¶ Bases:
object
-
provides_extra_context
()[source]¶ Override to add business logic if this module has any context to be added to the product context data.
-
extra_context
¶ Override this property to return wanted information to be added to the product context data. This property should return a dictionary which will be updated to the product context data.
-
shuup.front.utils.product_statistics module¶
shuup.front.utils.sorts_and_filters module¶
-
class
shuup.front.utils.sorts_and_filters.
ProductListFormModifier
[source]¶ Bases:
object
Interface class for modifying product lists
This interface can be used to sort and filter product lists in category and search view.
By subclassing this interface the ProductListForm fields can be added. Also this interface provides methods for sorting and filtering product lists.
-
should_use
(configuration)[source]¶ Parameters: configuration (dict) – current configurations Returns: Boolean whether the modifier should be used based on current configurations. :rtype: boolean
-
get_ordering
(configuration)[source]¶ Parameters: configuration (dict) – current configurations Returns: Ordering value based on configurations Return type: int
-
get_fields
(request, category=None)[source]¶ Extra fields for product list form.
Parameters: - request – Current request
- category (shuup.core.models.Category|None) – Current category
Returns: List of extra fields that should be added to form.
Tuple should contain field name and Django form field. :rtype: list[(str,django.forms.Field)]
-
get_choices_for_fields
()[source]¶ Provide sort choices for product list form
Returns: List of sort choices that should be added for form sort field. Tuple should contain sort key and label name. :rtype: list[(str,str)]
-
sort_products
(request, products, data)[source]¶ Sort products in case sort choices is provided
Sort products in cse the list should be sorted based on sort choice provided by this class.
Parameters: Returns: List of products that might be sorted
Return type: list[shuup.code.models.Product]
-
get_filters
(request, data)[source]¶ Get filters based for the product list view
Add Django query filters for Product queryset based on current request and ProductListForm data.
Parameters: - request – current request
- data (dict) – Data from ProductListForm
Returns: Django query filter that can be used to
filter Product queryset. :rtype: django.db.models.Q`
-
get_queryset
(queryset, data)[source]¶ Modify product queryset
Modify current queryset and return the new one. This can be used when there is need for stacking multiple filters for one queryset.
Returns: Updated product queryset Return type: Product.queryset
-
filter_products
(request, products, data)[source]¶ Filter product objects
Filtering products list based on current request and ProductListForm data.
Parameters: - request –
- products – List of products
- data (dict) – Data from ProductListForm
Rtype products: list[shuup.core.models.Product]
Returns: Filtered product list
Return type:
-
get_admin_fields
()[source]¶ Admin fields for sorts and filters configurations
Adds fields for sorts and filters admin configuration form.
Returns: List of fields that should be added to form. Tuple should contain field name and Django form field. :rtype: list[(str,django.forms.Field)]
-
clean_hook
(form)[source]¶ Extra clean for product list form.
This hook will be called in
clean
method of the form, after calling parent clean. Implementor of this hook may calladd_error
to add errors to form or modify theform.cleaned_data
dictionary.Parameters: form (ProductListForm) – Form that is currently cleaned Return type: None
-
-
class
shuup.front.utils.sorts_and_filters.
ProductListForm
(request, shop, category, *args, **kwargs)[source]¶ Bases:
django.forms.forms.Form
-
base_fields
= OrderedDict()¶
-
declared_fields
= OrderedDict()¶
-
media
¶
-
-
shuup.front.utils.sorts_and_filters.
get_configuration
(shop=None, category=None, force_category_override=False)[source]¶
-
shuup.front.utils.sorts_and_filters.
post_filter_products
(request, category, products, data)[source]¶
-
shuup.front.utils.sorts_and_filters.
get_product_queryset
(queryset, request, category, data)[source]¶