shuup.front.utils package

Submodules

shuup.front.utils.dashboard module

class shuup.front.utils.dashboard.DashboardItemSize[source]

Bases: enumfields.enums.Enum

An enumeration.

SMALL = <DashboardItemSize.SMALL: 6>
MEDIUM = <DashboardItemSize.MEDIUM: 9>
LARGE = <DashboardItemSize.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 = <django.utils.functional.lazy.<locals>.__proxy__ object>

The size of dashboard item block

size = <DashboardItemSize.LARGE: 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 = <django.utils.functional.lazy.<locals>.__proxy__ object>
request = None
url
get_context()[source]

Get context for template

This is usually overridden in subclasses.

Returns:Dict of context items
Return type:dict
render()[source]

Render the given template with context

Returns:Rendered template
css_class
show_on_menu()[source]

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
show_on_dashboard()[source]

Defines if the item is shown in dashboard

Returns:True or False if item should be shown in dashboard
Return type:bool

shuup.front.utils.product module

shuup.front.utils.product.get_product_context(request, product, language=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)[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

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/front/utils/sorts_and_filters.py:docstring of shuup.front.utils.sorts_and_filters.ProductListFormModifier.should_use, line 4)

Field list ends without a blank line; unexpected unindent.

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.

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/front/utils/sorts_and_filters.py:docstring of shuup.front.utils.sorts_and_filters.ProductListFormModifier.get_fields, line 7)

Field list ends without a blank line; unexpected unindent.

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

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/front/utils/sorts_and_filters.py:docstring of shuup.front.utils.sorts_and_filters.ProductListFormModifier.get_choices_for_fields, line 4)

Field list ends without a blank line; unexpected unindent.

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:
  • request – Current request
  • products (list[shuup.code.models.Product]) – Products to sort
  • data (dict) – product list form data
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

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/front/utils/sorts_and_filters.py:docstring of shuup.front.utils.sorts_and_filters.ProductListFormModifier.get_filters, line 10)

Field list ends without a blank line; unexpected unindent.

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:

list[shuup.core.models.Product]

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.

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/front/utils/sorts_and_filters.py:docstring of shuup.front.utils.sorts_and_filters.ProductListFormModifier.get_admin_fields, line 7)

Field list ends without a blank line; unexpected unindent.

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 call add_error to add errors to form or modify the form.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

clean()[source]
base_fields = OrderedDict()
declared_fields = OrderedDict()
media
shuup.front.utils.sorts_and_filters.get_configuration(shop=None, category=None)[source]
shuup.front.utils.sorts_and_filters.set_configuration(shop=None, category=None, data=None)[source]
shuup.front.utils.sorts_and_filters.get_query_filters(request, category, data)[source]
shuup.front.utils.sorts_and_filters.post_filter_products(request, category, products, data)[source]
shuup.front.utils.sorts_and_filters.sort_products(request, category, products, data)[source]
shuup.front.utils.sorts_and_filters.get_product_queryset(queryset, request, category, data)[source]

shuup.front.utils.views module

shuup.front.utils.views.cache_product_things(request, products, language=None, attribute_identifiers=('author', ))[source]

Module contents