shuup.simple_cms package

Subpackages

Submodules

shuup.simple_cms.layout module

class shuup.simple_cms.layout.PageLayout(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.

identifier = 'simple-cms-page-layout'
help_text = 'Content in this placeholder is shown for this page only.'
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

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

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

shuup.simple_cms.models module

class shuup.simple_cms.models.PageOpenGraphType(value)[source]

Bases: Enum

Website = 'website'
Article = 'article'
class shuup.simple_cms.models.PageQuerySet(*args, **kwargs)[source]

Bases: TranslatableQuerySet

not_deleted()[source]
visible(shop, dt=None, user=None)[source]

Get pages that should be publicly visible.

This does not do permission checking.

Parameters:

dt (datetime.datetime) – Datetime for visibility check.

Returns:

QuerySet of pages.

Return type:

QuerySet[Page]

for_user(user)[source]

Get pages that should be visible for the given user.

for_shop(shop)[source]
class shuup.simple_cms.models.Page(id, shop, supplier, available_from, available_to, created_by, modified_by, created_on, modified_on, identifier, visible_in_menu, parent, list_children_on_page, show_child_timestamps, deleted, template_name, render_title)[source]

Bases: MPTTModel, TranslatableModel

shop

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

supplier

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

available_from

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

available_to

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

available_permission_groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

created_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

modified_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

created_on

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_on

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

identifier

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

visible_in_menu

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

parent

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

list_children_on_page

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

show_child_timestamps

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deleted

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

translations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

template_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

render_title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.TreeManagerFromPageQuerySet object>
delete(using=None)[source]

Calling delete on a node will delete it as well as its full subtree, as opposed to reattaching all the subnodes to its parent node.

There are no argument specific to a MPTT model, all the arguments will be passed directly to the django’s Model.delete.

delete will not return anything.

soft_delete(user=None)[source]
clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

is_visible(dt=None)[source]
save(*args, **kwargs)[source]

If this is a new node, sets tree fields up before it is inserted into the database, making room in the tree structure as necessary, defaulting to making the new node the last child of its parent.

It the node’s left and right edge indicators already been set, we take this as indication that the node has already been set up for insertion, so its tree fields are left untouched.

If this is an existing node and its parent has been changed, performs reparenting in the tree structure, defaulting to making the node the last child of its new parent.

In either case, if the node’s class has its order_insertion_by tree option set, the node will be inserted or moved to the appropriate position to maintain ordering by the specified field.

get_html()[source]
classmethod create_initial_revision(page)[source]
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

add_log_entry(message, identifier=None, kind=LogEntryKind.OTHER, user=None, extra=None, save=True)
children

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

consent_settings

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

content

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

created_by_id
gdprsettings_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

gdpruserconsentdocument_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)
get_next_by_modified_on(*, field=<django.db.models.fields.DateTimeField: modified_on>, is_next=True, **kwargs)
get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)
get_previous_by_modified_on(*, field=<django.db.models.fields.DateTimeField: modified_on>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

level

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

lft

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

log_entries

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

modified_by_id
open_graph

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

parent_id
rght

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

shop_id
supplier_id
title

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

tree_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

url

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

class shuup.simple_cms.models.PageOpenGraph(*args, **kwargs)[source]

Bases: TranslatableModel

Object that describes Open Graph extra meta attributes.

page

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

image

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

og_type
translations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

article_author

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

description

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

get_og_type_display(*, field=<enumfields.fields.EnumField: og_type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

image_id
page_id
section

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

tags

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

title

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

class shuup.simple_cms.models.PageLogEntry(id, created_on, user, message, identifier, kind, extra, target)

Bases: BaseLogEntry

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

get_kind_display(*, field=<enumfields.fields.EnumIntegerField: kind>)
get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)
get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

kind
logged_model

alias of Page

objects = <django.db.models.manager.Manager object>
target

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

target_id
user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

class shuup.simple_cms.models.PageOpenGraphTranslation(id, language_code, title, description, section, tags, article_author, master)

Bases: TranslatedFieldsModel

exception DoesNotExist

Bases: TranslationDoesNotExist, DoesNotExist, DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

article_author

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_language_code_display(*, field=<parler.utils.compat.HideChoicesCharField: language_code>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

master

The mandatory Foreign key field to the shared model.

master_id
objects = <django.db.models.manager.Manager object>
section

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tags

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class shuup.simple_cms.models.PageTranslation(id, language_code, title, url, content, master)

Bases: TranslatedFieldsModel

exception DoesNotExist

Bases: TranslationDoesNotExist, DoesNotExist, DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

content

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_language_code_display(*, field=<parler.utils.compat.HideChoicesCharField: language_code>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

master

The mandatory Foreign key field to the shared model.

master_id
objects = <django.db.models.manager.Manager object>
title

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

shuup.simple_cms.plugins module

class shuup.simple_cms.plugins.OrderedModelMultipleChoiceField(queryset, required=True, widget=None, label=None, initial=None, help_text='', *args, **kwargs)[source]

Bases: ModelMultipleChoiceField

__init__(queryset, required=True, widget=None, label=None, initial=None, help_text='', *args, **kwargs)[source]
class shuup.simple_cms.plugins.PageLinksConfigForm(**kwargs)[source]

Bases: GenericPluginForm

A configuration for the PageLinksPlugin

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

A custom populate method to display page choices

clean()[source]

A custom clean method to save page configuration information in a serializable form

base_fields = {}
declared_fields = {}
property media

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

class shuup.simple_cms.plugins.PageLinksPlugin(config)[source]

Bases: TemplatedPlugin

A plugin for displaying links to visible CMS pages in the shop front

Instantiate a Plugin with the given config dictionary.

Parameters:

config (dict) – Dictionary of freeform configuration data

identifier = 'simple_cms.page_links'
name = 'CMS Page Links'
template_name = 'shuup/simple_cms/plugins/page_links.jinja'
cacheable = True
editor_form_class

alias of PageLinksConfigForm

fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('show_all_pages', <django.forms.fields.BooleanField object>), ('hide_expired', <django.forms.fields.BooleanField object>), 'pages']
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 method to return pages, possibly filtering expired pages based on the plugin’s hide_expired setting

shuup.simple_cms.settings module

shuup.simple_cms.settings.SHUUP_SIMPLE_CMS_DEFAULT_TEMPLATE = 'shuup/simple_cms/page.jinja'

Defines the default and fallback template to be used when rendering CMS pages

shuup.simple_cms.template_helpers module

class shuup.simple_cms.template_helpers.SimpleCMSTemplateHelpers[source]

Bases: object

name = 'simple_cms'
get_page_by_identifier(context, identifier)[source]
get_visible_pages(context)[source]

shuup.simple_cms.templates module

class shuup.simple_cms.templates.SimpleCMSDefaultTemplate[source]

Bases: object

name = 'Default Page'
template_path = 'shuup/simple_cms/page.jinja'
class shuup.simple_cms.templates.SimpleCMSTemplateSidebar[source]

Bases: object

name = 'Page with sidebar'
template_path = 'shuup/simple_cms/page_sidebar.jinja'

shuup.simple_cms.urls module

shuup.simple_cms.utils module

shuup.simple_cms.utils.order_query_by_values(queryset, values)[source]

shuup.simple_cms.views module

class shuup.simple_cms.views.PageView(**kwargs)[source]

Bases: DetailView

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

model

alias of Page

slug_field = 'translations__url'
slug_url_kwarg = 'url'
template_name = 'shuup/simple_cms/page.jinja'
context_object_name = 'page'
get(request, *args, **kwargs)[source]

Override normal get method to return correct page based on the active language and slug

Cases:
  1. Page is not found: raise Http404() like django would.

  2. No translation in active language for the page: raise Http404().

  3. Translation was found for active language, but the url doesn’t match given url:

    return HttpResponseRedirect to the active languages url.

  4. If none of the upper matches: render page normally.

get_template_names()[source]

Return a list of template names to be used for the request. May not be called if render_to_response() is overridden. Return the following list:

  • the value of template_name on the view (if provided)

  • the contents of the template_name_field field on the object instance that the view is operating upon (if available)

  • <app_label>/<model_name><template_name_suffix>.html

get_queryset()[source]

Return the QuerySet that will be used to look up the object.

This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.

Module contents

class shuup.simple_cms.AppConfig(*args, **kwargs)[source]

Bases: AppConfig

name = 'shuup.simple_cms'
verbose_name = 'Content Pages'
label = 'shuup_simple_cms'
default_auto_field = 'django.db.models.BigAutoField'
provides = {'admin_module': ['shuup.simple_cms.admin_module:SimpleCMSAdminModule'], 'admin_page_form_part': ['shuup.simple_cms.admin_module.form_parts:CMSOpenGraphFormPart'], 'front_template_helper_namespace': ['shuup.simple_cms.template_helpers:SimpleCMSTemplateHelpers'], 'front_urls_post': ['shuup.simple_cms.urls:urlpatterns'], 'simple_cms_template': ['shuup.simple_cms.templates:SimpleCMSDefaultTemplate', 'shuup.simple_cms.templates:SimpleCMSTemplateSidebar'], 'xtheme_layout': ['shuup.simple_cms.layout:PageLayout'], 'xtheme_plugin': ['shuup.simple_cms.plugins:PageLinksPlugin']}

See /provides for details about the provides variable.

ready()[source]

Override this method in subclasses to run code when Django starts.