shuup.xtheme.layout package

Submodules

shuup.xtheme.layout.utils module

shuup.xtheme.layout.utils.get_customer_from_context(context)[source]
shuup.xtheme.layout.utils.get_layout_data_key(placeholder_name, layout, context)[source]
shuup.xtheme.layout.utils.get_provided_layouts()[source]

Module contents

class shuup.xtheme.layout.AnonymousContactLayout(theme, placeholder_name, rows=None)[source]

Bases: Layout

Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

get_help_text(context)[source]

Help text for this placeholder box shown at the top of the editable layout.

Parameters:

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

Returns:

Help text for this layout.

Return type:

str

get_layout_data_suffix(context)[source]

Layout data suffix which is used to save layout data to view config.

With layout data suffix you can define data keys that is only available for certain contexts. Make sure that you validate the context for variables that is used to form this suffix.

Parameters:

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

Return type:

str

identifier = 'xtheme-anonymous-contact-layout'
is_valid_context(context)[source]
Parameters:

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

Returns:

Whether the current context is valid for this layout.

Return type:

bool

class shuup.xtheme.layout.CategoryLayout(theme, placeholder_name, rows=None)[source]

Bases: Layout

Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

get_help_text(context)[source]

Help text for this placeholder box shown at the top of the editable layout.

Parameters:

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

Returns:

Help text for this layout.

Return type:

str

get_layout_data_suffix(context)[source]

Layout data suffix which is used to save layout data to view config.

With layout data suffix you can define data keys that is only available for certain contexts. Make sure that you validate the context for variables that is used to form this suffix.

Parameters:

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

Return type:

str

identifier = 'xtheme-category-layout'
is_valid_context(context)[source]
Parameters:

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

Returns:

Whether the current context is valid for this layout.

Return type:

bool

class shuup.xtheme.layout.CompanyContactLayout(theme, placeholder_name, rows=None)[source]

Bases: Layout

Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

get_help_text(context)[source]

Help text for this placeholder box shown at the top of the editable layout.

Parameters:

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

Returns:

Help text for this layout.

Return type:

str

get_layout_data_suffix(context)[source]

Layout data suffix which is used to save layout data to view config.

With layout data suffix you can define data keys that is only available for certain contexts. Make sure that you validate the context for variables that is used to form this suffix.

Parameters:

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

Return type:

str

identifier = 'xtheme-company-contact-layout'
is_valid_context(context)[source]
Parameters:

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

Returns:

Whether the current context is valid for this layout.

Return type:

bool

class shuup.xtheme.layout.ContactLayout(theme, placeholder_name, rows=None)[source]

Bases: Layout

Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

get_help_text(context)[source]

Help text for this placeholder box shown at the top of the editable layout.

Parameters:

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

Returns:

Help text for this layout.

Return type:

str

get_layout_data_suffix(context)[source]

Layout data suffix which is used to save layout data to view config.

With layout data suffix you can define data keys that is only available for certain contexts. Make sure that you validate the context for variables that is used to form this suffix.

Parameters:

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

Return type:

str

identifier = 'xtheme-contact-layout'
is_valid_context(context)[source]
Parameters:

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

Returns:

Whether the current context is valid for this layout.

Return type:

bool

class shuup.xtheme.layout.Layout(theme, placeholder_name, rows=None)[source]

Bases: object

The layout (row, cell and plugin configuration) for a single placeholder.

Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

__init__(theme, placeholder_name, rows=None)[source]
Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

add_plugin(plugin_identifier, config)[source]

Configure a plugin in the last row and cell of the layout.

If no rows or cells exist, one row and one cell is implicitly created.

This is internally used by LayoutPartExtension, but could just as well be used to programmatically create layouts for whichever purpose.

Parameters:
  • plugin_identifier (str) – Plugin identifier string.

  • config (dict) – Configuration dict.

Returns:

The configured cell.

Return type:

LayoutCell

begin_column(sizes=None)[source]

Begin a new column (cell) in the layout, in the last row.

If no rows exist, one is implicitly created, for your convenience. The newly created cell has no plugin or configuration.

This is internally used by LayoutPartExtension, but could just as well be used to programmatically create layouts for whichever purpose.

Parameters:

sizes – The size dictionary to pass to LayoutCell.

Returns:

The newly created cell

Return type:

LayoutCell

begin_row()[source]

Begin a new row in the layout.

This is internally used by LayoutPartExtension, but could just as well be used to programmatically create layouts for whichever purpose.

Returns:

The newly created row.

Return type:

LayoutRow

cell_class_template = 'col-%(breakpoint)s-%(width)s'
delete_cell(x, y)[source]

Delete a layout cell indicated by the given (zero-based) coordinates.

If the coordinates are out of range, nothing is done.

Parameters:
  • x (int) – X (horizontal) coordinate.

  • y (int) – Y (vertical) coordinate.

Returns:

Was something done?

Return type:

bool

delete_row(y)[source]

Delete the y’th (zero-based) row.

If y is out of bounds, nothing is done.

Parameters:

y (int) – Y coordinate.

Returns:

Was something done?

Return type:

bool

get_cell(x, y)[source]

Get a layout cell indicated by the given (zero-based) coordinates.

If the coordinates are out of range, returns None.

Parameters:
  • x (int) – X (horizontal) coordinate.

  • y (int) – Y (vertical) coordinate.

Returns:

Layout cell.

Return type:

LayoutCell|None

get_help_text(context)[source]

Help text for this placeholder box shown at the top of the editable layout.

Parameters:

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

Returns:

Help text for this layout.

Return type:

str

get_layout_data_suffix(context)[source]

Layout data suffix which is used to save layout data to view config.

With layout data suffix you can define data keys that is only available for certain contexts. Make sure that you validate the context for variables that is used to form this suffix.

Parameters:

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

Return type:

str

hide_cell_class_template = 'hidden-%(breakpoint)s'
identifier = 'xtheme-default-layout'
insert_row(y=None)[source]

Insert a new row at the given zero-based row and return it.

If y is None, the row in inserted at the end.

Parameters:

y (int) – Y coordinate.

Returns:

The new layout row.

Return type:

LayoutRow

is_valid_context(context)[source]
Parameters:

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

Returns:

Whether the current context is valid for this layout.

Return type:

bool

move_cell_to_position(from_x, from_y, to_x, to_y)[source]

Move the layout cell to the specified zero-based coordinates.

If the coordinates are out of range, nothing is done.

Parameters:
  • from_x (int) – X (horizontal) coordinate of the cell to move.

  • from_y (int) – Y (vertical) coordinate of the cell to move.

  • to_x (int) – X (horizontal) coordinate of the cell after moving.

  • to_y (int) – Y (vertical) coordinate of the cell after moving.

Returns:

Was something done?

Return type:

bool

move_row_to_index(from_y, to_y)[source]

Move the y’th row to the specified zero-based index.

If y or index are out of bounds, nothing is done.

Parameters:
  • from_y (int) – current Y coordinate.

  • to_y (int) – new Y coordinate.

Returns:

Was something done?

Return type:

bool

row_class = 'row'
serialize()[source]

Serialize this layout into a dict.

Returns:

Layout data dict.

Return type:

dict

classmethod unserialize(theme, data, placeholder_name=None)[source]

Unserialize a dict of layout data into a new layout, with all rows and cells.

Parameters:
  • data (dict) – Layout data dict.

  • placeholder_name (str) – Placeholder name if none is specified in the data.

Returns:

New layout.

Return type:

Layout

class shuup.xtheme.layout.LayoutCell(theme, plugin_identifier, config=None, sizes=None, align='', extra_classes='')[source]

Bases: object

A single cell in a layout. Maps to Bootstrap’s col-XX-XX classes.

Initialize a layout cell with a given plugin, config and sizing configuration.

Parameters:
  • plugin_identifier (str) – Plugin identifier string.

  • config (dict|None) – Config dict.

  • sizes (dict|None) – Size dict.

  • align (str) – Align string.

__init__(theme, plugin_identifier, config=None, sizes=None, align='', extra_classes='')[source]

Initialize a layout cell with a given plugin, config and sizing configuration.

Parameters:
  • plugin_identifier (str) – Plugin identifier string.

  • config (dict|None) – Config dict.

  • sizes (dict|None) – Size dict.

  • align (str) – Align string.

instantiate_plugin()[source]

Instantiate the plugin with the current config.

Returns:

Instantiated plugin (if a class is available).

Return type:

Plugin|None

property plugin_class

Get the actual plugin class for this cell, or None if the plugin class isn’t available.

Returns:

Plugin or None.

Return type:

Plugin|None

property plugin_name

Get the name of the plugin in this cell for display purposes.

Returns:

Plugin name string.

Return type:

str

render(context, cache_key_prefix=None)[source]

Return the plugin’s rendered content.

Parameters:

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

Returns:

string of content.

Return type:

str

serialize()[source]

Serialize this cell into a dict.

Returns:

Layout cell data dict.

Return type:

dict

classmethod unserialize(theme, data)[source]

Unserialize a dict of layout cell data into a new cell.

Parameters:

data (dict) – Layout cell data dict.

Returns:

New cell.

Return type:

LayoutCell

class shuup.xtheme.layout.LayoutRow(theme, cells=None)[source]

Bases: object

A single row in a layout. Maps to Bootstrap’s row class.

Parameters:

cells – Optional iterable of LayoutCells to populate this LayoutRow with.

__init__(theme, cells=None)[source]
Parameters:

cells – Optional iterable of LayoutCells to populate this LayoutRow with.

add_cell(sizes=None)[source]

Add an empty cell to this row. Used by the editor API.

Parameters:

sizes (dict|None) – An optional size dict, see LayoutCell.

Returns:

The new layout cell.

Return type:

LayoutCell

serialize()[source]

Serialize this row into a dict.

Returns:

Layout row data dict.

Return type:

dict

classmethod unserialize(theme, data)[source]

Unserialize a dict of layout row data into a new row, along with all cell children.

Parameters:

data (dict) – Layout row data dict.

Returns:

New row.

Return type:

LayoutRow

class shuup.xtheme.layout.PersonContactLayout(theme, placeholder_name, rows=None)[source]

Bases: Layout

Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

get_help_text(context)[source]

Help text for this placeholder box shown at the top of the editable layout.

Parameters:

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

Returns:

Help text for this layout.

Return type:

str

get_layout_data_suffix(context)[source]

Layout data suffix which is used to save layout data to view config.

With layout data suffix you can define data keys that is only available for certain contexts. Make sure that you validate the context for variables that is used to form this suffix.

Parameters:

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

Return type:

str

identifier = 'xtheme-person-contact-layout'
is_valid_context(context)[source]
Parameters:

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

Returns:

Whether the current context is valid for this layout.

Return type:

bool

class shuup.xtheme.layout.ProductLayout(theme, placeholder_name, rows=None)[source]

Bases: Layout

Parameters:
  • placeholder_name (str|None) – The name of the placeholder. Could be None.

  • rows (Iterable[LayoutRow]|None) – Optional iterable of LayoutRows to populate this Layout with.

get_help_text(context)[source]

Help text for this placeholder box shown at the top of the editable layout.

Parameters:

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

Returns:

Help text for this layout.

Return type:

str

get_layout_data_suffix(context)[source]

Layout data suffix which is used to save layout data to view config.

With layout data suffix you can define data keys that is only available for certain contexts. Make sure that you validate the context for variables that is used to form this suffix.

Parameters:

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

Return type:

str

identifier = 'xtheme-product-layout'
is_valid_context(context)[source]
Parameters:

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

Returns:

Whether the current context is valid for this layout.

Return type:

bool