shuup.front.utils package

Submodules

shuup.front.utils.cache module

shuup.front.utils.cache.get_listed_products_cache_item(shop: Shop | int)[source]
shuup.front.utils.cache.get_best_selling_products_cache_item(shop: Shop | int)[source]
shuup.front.utils.cache.get_newest_products_cache_item(shop: Shop | int)[source]
shuup.front.utils.cache.get_random_products_cache_item(shop: Shop | int)[source]
shuup.front.utils.cache.get_products_for_category_cache_item(shop: Shop | int)[source]
shuup.front.utils.cache.get_all_manufacturers_cache_item(shop: Shop | int)[source]
shuup.front.utils.cache.get_cross_sells_cache_item(shop: Shop | int)[source]

shuup.front.utils.companies module

shuup.front.utils.companies.allow_company_registration(shop)[source]
shuup.front.utils.companies.company_registration_requires_approval(shop)[source]
shuup.front.utils.companies.validate_tax_number(shop)[source]
class shuup.front.utils.companies.TaxNumberCleanMixin[source]

Bases: object

company_name_field = 'name'
clean_tax_number()[source]

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'
__init__(request)[source]
request = None
property 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

property 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.order_source module

class shuup.front.utils.order_source.LineProperty(name, value)[source]

Bases: object

__init__(name, value)[source]
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:

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

__init__(request, product, language, **kwargs)[source]
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.product_statistics.get_products_by_same_categories(prod, count=6, request=None, language=None)[source]
shuup.front.utils.product_statistics.get_products_ordered_with(prod, count=20, 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_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:
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 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: Form

__init__(request, shop, category, *args, **kwargs)[source]
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.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.sort_products(request, category, products: QuerySet, data)[source]
shuup.front.utils.sorts_and_filters.bump_product_queryset_cache()[source]
shuup.front.utils.sorts_and_filters.get_product_queryset(queryset, request, category, data)[source]
shuup.front.utils.sorts_and_filters.cached_product_queryset(queryset, request, category, data)[source]

Returns the cached queryset or cache it when needed Note: this method returns a list of Product instances rtype: list[Product]

shuup.front.utils.sorts_and_filters.get_form_field_label(identifier, default)[source]

shuup.front.utils.translation module

shuup.front.utils.translation.get_language_choices(shop=None)[source]
Returns a list of the available language choices, e.g.:

[(“en”, “English”, “English”])

If a shop is passed, the languages will be filtered by those enabled for that shop.

:rtype iterable[(str, str, str)]

shuup.front.utils.translation.set_shop_available_languages(shop, languages)[source]
shuup.front.utils.translation.get_shop_available_languages(shop)[source]

shuup.front.utils.urls module

shuup.front.utils.urls.model_url(context, model, absolute=False, **kwargs)[source]

shuup.front.utils.user module

shuup.front.utils.user.is_admin_user(request)[source]

shuup.front.utils.views module

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

Module contents