shuup.xtheme.plugins package

Submodules

shuup.xtheme.plugins.consts module

shuup.xtheme.plugins.consts.FALLBACK_LANGUAGE_CODE = '*'

The pseudo-language code used by TranslatedFields and the relevant Plugin API to mark the untranslated/fallback content

shuup.xtheme.plugins.forms module

class shuup.xtheme.plugins.forms.PluginForm(**kwargs)[source]

Bases: Form

Base class for plugin configuration forms.

__init__(**kwargs)[source]
populate()[source]
init_translated_fields()[source]
set_defaults()[source]

Set the forms initial values based on plugin defaults

Use the plugin’s default configuration as the default form field initial values.

full_clean()[source]

Use initial values as defaults for cleaned data

get_config()[source]

Get the new config dict for a plugin.

Called when the form is valid, akin to django.forms.models.ModelForm.save.

The default implementation just augments the old config with the cleaned data for the form.

Returns:

A new JSONable (!) config dict

Return type:

dict

get_languages()[source]
base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class shuup.xtheme.plugins.forms.GenericPluginForm(**kwargs)[source]

Bases: PluginForm

A generic form for Xtheme plugins; populates itself based on fields in the plugin class.

populate()[source]
base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class shuup.xtheme.plugins.forms.TranslatableField(*, required=True, widget=None, label=None, initial=None, help_text='', error_messages=None, show_hidden_initial=False, validators=(), localize=False, disabled=False, label_suffix=None)[source]

Bases: Field

shuup.xtheme.plugins.image module

class shuup.xtheme.plugins.image.ImagePluginChoiceWidget(attrs=None, clearable=False, empty_text=True)[source]

Bases: ImageChoiceWidget

Subclass of ImageChoiceWidget that will not raise an exception if given an invalid initial image ID (in case the image has been deleted).

get_object(value)[source]
property media
class shuup.xtheme.plugins.image.ImageIDField(*, max_value=None, min_value=None, **kwargs)[source]

Bases: IntegerField

A custom field that stores the ID value of a Filer image and presents Shuup admin’s image popup widget.

widget = <shuup.xtheme.plugins.image.ImagePluginChoiceWidget object>
clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

class shuup.xtheme.plugins.image.ImagePlugin(config)[source]

Bases: TemplatedPlugin

A linkable image plugin.

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'images'
name = 'Image'
template_name = 'shuup/xtheme/plugins/image.jinja'
cacheable = True
fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('image_id', <shuup.xtheme.plugins.image.ImageIDField object>), ('url', <django.forms.fields.URLField object>), ('full_width', <django.forms.fields.BooleanField object>), ('width', <django.forms.fields.IntegerField object>), ('height', <django.forms.fields.IntegerField object>)]
get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

A custom get_context_data that returns the matching filer File.

shuup.xtheme.plugins.products module

class shuup.xtheme.plugins.products.HighlightType(value)[source]

Bases: Enum

NEWEST = 'newest'
BEST_SELLING = 'best_selling'
RANDOM = 'random'
class shuup.xtheme.plugins.products.ProductHighlightPlugin(config)[source]

Bases: TemplatedPlugin

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'product_highlight'
name = 'Product Highlights'
template_name = 'shuup/xtheme/plugins/highlight_plugin.jinja'
cacheable = True
fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('type', <django.forms.fields.ChoiceField object>), ('count', <django.forms.fields.IntegerField object>), ('orderable_only', <django.forms.fields.BooleanField object>)]
get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

class shuup.xtheme.plugins.products.ProductCrossSellsPlugin(config)[source]

Bases: TemplatedPlugin

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'product_cross_sells'
name = 'Product Cross Sells'
template_name = 'shuup/xtheme/plugins/cross_sells_plugin.jinja'
cacheable = True
required_context_variables = ['product']
fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('type', <enumfields.forms.EnumChoiceField object>), ('count', <django.forms.fields.IntegerField object>), ('use_variation_parents', <django.forms.fields.BooleanField object>), ('orderable_only', <django.forms.fields.BooleanField object>)]
__init__(config)[source]

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

class shuup.xtheme.plugins.products.ProductsFromCategoryForm(**kwargs)[source]

Bases: GenericPluginForm

populate()[source]
base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class shuup.xtheme.plugins.products.ProductsFromCategoryPlugin(config)[source]

Bases: TemplatedPlugin

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'category_products'
name = 'Category Products Highlight'
template_name = 'shuup/xtheme/plugins/highlight_plugin.jinja'
editor_form_class

alias of ProductsFromCategoryForm

cacheable = True
fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('count', <django.forms.fields.IntegerField object>), ('orderable_only', <django.forms.fields.BooleanField object>)]
get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

class shuup.xtheme.plugins.products.ProductSelectionConfigForm(**kwargs)[source]

Bases: GenericPluginForm

A configuration form for the ProductSelectionPlugin

populate()[source]

A custom populate method to display product choices

base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class shuup.xtheme.plugins.products.ProductSelectionPlugin(config)[source]

Bases: TemplatedPlugin

A plugin that renders a selection of products

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'product_selection'
name = 'Product Selection'
template_name = 'shuup/xtheme/plugins/product_selection_plugin.jinja'
editor_form_class

alias of ProductSelectionConfigForm

cacheable = True
fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>)]
get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

shuup.xtheme.plugins.products_async module

class shuup.xtheme.plugins.products_async.HighlightType(value)[source]

Bases: Enum

NEWEST = 'newest'
BEST_SELLING = 'best_selling'
RANDOM = 'random'
class shuup.xtheme.plugins.products_async.ProductHighlightPlugin(config)[source]

Bases: TemplatedPlugin

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'async_product_highlight'
name = 'Product Highlights (asynchronous)'
template_name = 'shuup/xtheme/plugins/highlight_plugin_async.jinja'
cacheable = True
fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('type', <django.forms.fields.ChoiceField object>), ('count', <django.forms.fields.IntegerField object>), ('cutoff_days', <django.forms.fields.IntegerField object>), ('cache_timeout', <django.forms.fields.IntegerField object>), ('orderable_only', <django.forms.fields.BooleanField object>)]
get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

class shuup.xtheme.plugins.products_async.ProductCrossSellsPlugin(config)[source]

Bases: TemplatedPlugin

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'async_product_cross_sells'
name = 'Product Cross Sells (asynchronous)'
template_name = 'shuup/xtheme/plugins/highlight_plugin_async.jinja'
required_context_variables = ['product']
fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('type', <enumfields.forms.EnumChoiceField object>), ('count', <django.forms.fields.IntegerField object>), ('use_variation_parents', <django.forms.fields.BooleanField object>), ('cache_timeout', <django.forms.fields.IntegerField object>), ('orderable_only', <django.forms.fields.BooleanField object>)]
__init__(config)[source]

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

class shuup.xtheme.plugins.products_async.ProductsFromCategoryForm(**kwargs)[source]

Bases: GenericPluginForm

populate()[source]
base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class shuup.xtheme.plugins.products_async.ProductsFromCategoryPlugin(config)[source]

Bases: TemplatedPlugin

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'async_category_products'
name = 'Category Products Highlight (asynchronous)'
template_name = 'shuup/xtheme/plugins/highlight_plugin_async.jinja'
editor_form_class

alias of ProductsFromCategoryForm

fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('count', <django.forms.fields.IntegerField object>), ('cache_timeout', <django.forms.fields.IntegerField object>), ('orderable_only', <django.forms.fields.BooleanField object>)]
get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

class shuup.xtheme.plugins.products_async.ProductSelectionConfigForm(**kwargs)[source]

Bases: GenericPluginForm

A configuration form for the ProductSelectionPlugin

populate()[source]

A custom populate method to display product choices

base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class shuup.xtheme.plugins.products_async.ProductSelectionPlugin(config)[source]

Bases: TemplatedPlugin

A plugin that renders a selection of products

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'async_product_selection'
name = 'Product Selection (asynchronous)'
template_name = 'shuup/xtheme/plugins/highlight_plugin_async.jinja'
editor_form_class

alias of ProductSelectionConfigForm

fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('cache_timeout', <django.forms.fields.IntegerField object>)]
get_cache_key(context, **kwargs) str[source]

Return a string that is used as the cache key when the plugin can be cached

get_context_data(context)[source]

Get a context dictionary from a Jinja2 context.

Parameters:

context (jinja2.runtime.Context) – Jinja2 rendering context

Returns:

Dict of vars

Return type:

dict[str, object]

shuup.xtheme.plugins.snippets module

class shuup.xtheme.plugins.snippets.SnippetsPlugin(config)[source]

Bases: Plugin

Simple plugin class for including snippets and resources on the page, mostly for simple integrations.

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'snippets'
name = 'Snippets'
fields = [('in_place', <django.forms.fields.CharField object>), ('head_start', <django.forms.fields.CharField object>), ('head_end', <django.forms.fields.CharField object>), ('body_start', <django.forms.fields.CharField object>), ('body_end', <django.forms.fields.CharField object>)]
render(context)[source]

Return the HTML for a plugin in a given rendering context.

Parameters:

context (jinja2.runtime.Context) – Rendering context

Returns:

String of rendered content.

Return type:

str

shuup.xtheme.plugins.text module

class shuup.xtheme.plugins.text.TextPlugin(config)[source]

Bases: Plugin

Very basic Markdown rendering plugin.

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'text'
name = 'Text'
fields = [('text', <shuup.xtheme.plugins.forms.TranslatableField object>)]
render(context)[source]

Return the HTML for a plugin in a given rendering context.

Parameters:

context (jinja2.runtime.Context) – Rendering context

Returns:

String of rendered content.

Return type:

str

shuup.xtheme.plugins.widgets module

class shuup.xtheme.plugins.widgets.XThemeModelChoiceWidget(attrs=None, choices=())[source]

Bases: Select

render(name, value, attrs=None, choices=(), renderer=None)[source]

Render the widget as an HTML string.

property media
class shuup.xtheme.plugins.widgets.XThemeModelChoiceField(queryset, *, empty_label='---------', required=True, widget=None, label=None, initial=None, help_text='', to_field_name=None, limit_choices_to=None, blank=False, **kwargs)[source]

Bases: ModelChoiceField

widget

alias of XThemeModelChoiceWidget

label_from_instance(obj)[source]

Convert objects into strings and generate the labels for the choices presented by this object. Subclasses can override this method to customize the display of the choices.

class shuup.xtheme.plugins.widgets.XThemeSelect2ModelMultipleChoiceField(model, required=True, label=None, initial=None, help_text='', extra_widget_attrs=None, *args, **kwargs)[source]

Bases: MultipleChoiceField

__init__(model, required=True, label=None, initial=None, help_text='', extra_widget_attrs=None, *args, **kwargs)[source]
validate(value)[source]

Validate that the input is a list or tuple.

class shuup.xtheme.plugins.widgets.XThemeSelect2ModelChoiceField(model, required=True, label=None, initial=None, help_text='', extra_widget_attrs=None, *args, **kwargs)[source]

Bases: ChoiceField

__init__(model, required=True, label=None, initial=None, help_text='', extra_widget_attrs=None, *args, **kwargs)[source]
validate(value)[source]

Validate that the input is in self.choices.

Module contents