shuup.front.utils package
Submodules
shuup.front.utils.cache module
shuup.front.utils.companies module
shuup.front.utils.dashboard module
- class shuup.front.utils.dashboard.DashboardItemSize(value)[source]
Bases:
Enum
- 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
- property url
- get_context()[source]
Get context for template
This is usually overridden in subclasses.
- Returns:
Dict of context items
- Return type:
- property 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:
shuup.front.utils.order_source module
- class shuup.front.utils.order_source.LineProperty(name, value)[source]
Bases:
object
- name = None
- value = None
- class shuup.front.utils.order_source.BaseLinePropertiesDescriptor[source]
Bases:
object
- classmethod get_line_properties(line: OrderLine | SourceLine, **kwargs) Iterable[LineProperty] [source]
- shuup.front.utils.order_source.get_line_properties(line: OrderLine | SourceLine) Iterable[LineProperty] [source]
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:
- 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.
- property 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.product_statistics.get_best_selling_product_info(shop_ids, cutoff_days=30, supplier=None, orderable_only=True, quantity=100)[source]
- shuup.front.utils.product_statistics.get_products_by_brand(prod, count=6, request=None, language=None)[source]
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_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_queryset(request, queryset: QuerySet, data: Dict)[source]
Sort the products queryset Modify current queryset and return the new one.
- get_filters(request, data: Dict) Q [source]
Get filters based for the product list view
Add Django query filters for Product queryset based on current request and ProductListForm data.
- get_products_queryset(request, queryset: QuerySet, data: Dict) QuerySet [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
- 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:
Form
- clean()[source]
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- base_fields = {}
- declared_fields = {}
- property media
Return all media required to render the widgets on this form.
- shuup.front.utils.sorts_and_filters.get_configuration(shop=None, category=None, force_category_override=False)[source]
- shuup.front.utils.sorts_and_filters.sort_products(request, category, products: QuerySet, data)[source]
- shuup.front.utils.sorts_and_filters.get_product_queryset(queryset, request, category, data)[source]