shuup.xtheme.layout package¶
Submodules¶
shuup.xtheme.layout.utils module¶
Module contents¶
-
class
shuup.xtheme.layout.
AnonymousContactLayout
(theme, placeholder_name, rows=None)[source]¶ Bases:
shuup.xtheme.layout._base.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.
-
identifier
= 'xtheme-anonymous-contact-layout'¶
-
class
shuup.xtheme.layout.
CategoryLayout
(theme, placeholder_name, rows=None)[source]¶ Bases:
shuup.xtheme.layout._base.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.
-
identifier
= 'xtheme-category-layout'¶
-
class
shuup.xtheme.layout.
CompanyContactLayout
(theme, placeholder_name, rows=None)[source]¶ Bases:
shuup.xtheme.layout._base.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.
-
identifier
= 'xtheme-company-contact-layout'¶
-
class
shuup.xtheme.layout.
ContactLayout
(theme, placeholder_name, rows=None)[source]¶ Bases:
shuup.xtheme.layout._base.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.
-
identifier
= 'xtheme-contact-layout'¶
-
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.
-
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: Returns: The configured cell.
Return type:
-
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: Returns: Was something done?
Return type:
-
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: 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: Returns: Was something done?
Return type:
-
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: Returns: Was something done?
Return type:
-
row_class
= 'row'¶
-
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: -
instantiate_plugin
()[source]¶ Instantiate the plugin with the current config.
Returns: Instantiated plugin (if a class is available). Return type: Plugin|None
-
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
-
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. -
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
-
-
class
shuup.xtheme.layout.
PersonContactLayout
(theme, placeholder_name, rows=None)[source]¶ Bases:
shuup.xtheme.layout._base.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.
-
identifier
= 'xtheme-person-contact-layout'¶
-
class
shuup.xtheme.layout.
ProductLayout
(theme, placeholder_name, rows=None)[source]¶ Bases:
shuup.xtheme.layout._base.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.
-
identifier
= 'xtheme-product-layout'¶