pagetools.sections package

Subpackages

Submodules

pagetools.sections.admin module

class pagetools.sections.admin.BasePageNodeAdmin(model, admin_site)[source]

Bases: PagelikeAdmin

change_form_template = 'admin/change_form_chooser.html'
containing_nodes(instance)[source]
get_queryset(request)[source]

Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.

inlines = [<class 'pagetools.sections.admin.BasePageNodePosAdmin'>]
property media
prepopulated_fields = {'slug': ('title',)}
readonly_fields = ('status_changed', 'containing_nodes')
class pagetools.sections.admin.BasePageNodePosAdmin(parent_model, admin_site)[source]

Bases: AdminLinkMixin, GrappelliSortableHiddenMixin, TabularInline

extra = 1
fk_name = 'owner'
formfield_for_foreignkey(db_field, request, **kwargs)[source]

Get a form Field for a ForeignKey.

get_queryset(request)[source]

Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.

has_add_permission(request, obj=None)[source]

Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.

property media
model

alias of PageNodePos

readonly_fields = ('admin_link',)
sortable_field_name = 'position'

pagetools.sections.dashboard_modules module

class pagetools.sections.dashboard_modules.PageNodesModule(*args, **kwargs)[source]

Bases: DashboardModule

A module that displays a page with nodes.

A “page” should be the root-pagenode model. Overwrite model = <YourModel>

Dashboard needs to include the static files, e.g:

from django import forms
...
def _media(self):
        return forms.Media(
            js=["
                "js/jquery-bonsai/jquery.bonsai.js",
                "js/nodetree.js"
                ],
            css = {'all': [
            'bower_components/jquery-bonsai/jquery.bonsai.css ']}
        )

media = property(_media)

urls.py:
    url(
        r'^adminnodes/(?P<slug>[\w-]+)/$',
        admin_pagenodesview,
        name='admin_pagenodesview'),
init_with_context(context)[source]

Like for the Dashboard class, dashboard modules have a init_with_context method that is called with a django.template.RequestContext instance as unique argument.

This gives you enough flexibility to build complex modules, for example, let’s build a “history” dashboard module, that will list the last ten visited pages:

from grappelli.dashboard import modules

class HistoryDashboardModule(modules.LinkList):
    title = 'History'

    def init_with_context(self, context):
        request = context['request']
        # we use sessions to store the visited pages stack
        history = request.session.get('history', [])
        for item in history:
            self.children.append(item)
        # add the current page to the history
        history.insert(0, {
            'title': context['title'],
            'url': request.META['PATH_INFO']
        })
        if len(history) > 10:
            history = history[:10]
        request.session['history'] = history
model = None
template = 'admin/dashboard_pagenodes_module.html'

pagetools.sections.models module

Nested content (e.g. for single pages) A PageNode is a model which may contains other PageNodes. Inheritated models with own fields needs concrete inheritance, otherwise a proxy model is sufficient.

class pagetools.sections.models.PageNode(id, created, modified, status, status_changed, lang, title, slug, description, classes, content_type_pk)[source]

Bases: PagelikeModel

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

allowed_children_classes: List[str | Type[Model]] = []
article

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.

children(**_kwargs)[source]
children_queryset(**kwargs)[source]
classes

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

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.

content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

content_type_pk

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.

content_type_pk_id
created

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.

draft = <model_utils.managers.QueryManager object>
get_absolute_url()[source]

Dummy

classmethod get_adminadd_url()[source]
get_classname()[source]
classmethod get_contenttype_pk()[source]
get_lang_display(*, field=<django.db.models.fields.CharField: lang>)
get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)
get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)
get_next_by_status_changed(*, field=<model_utils.fields.MonitorField: status_changed>, is_next=True, **kwargs)
get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)
get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)
get_previous_by_status_changed(*, field=<model_utils.fields.MonitorField: status_changed>, is_next=False, **kwargs)
get_real_obj()[source]
get_status_display(*, field=<model_utils.fields.StatusField: status>)
id

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

in_group

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.

in_nodes

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.

lang

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

modified

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

objects = <pagetools.sections.models.PageNodeManager object>
ordered_content(**kwargs)[source]
pagenodepos_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.

positioned_content

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.

published = <model_utils.managers.QueryManager object>
save(*args, **kwargs)[source]

Overriding the save method in order to make sure that modified field is updated even if it is not given as a parameter to the update field argument.

section

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.

slug

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

status

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

status_changed

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 pagetools.sections.models.PageNodeManager(*args, **kwargs)[source]

Bases: PublishableLangManager

class pagetools.sections.models.PageNodePos(id, position, content, owner)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

content

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.

content_id
id

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.Manager object>
owner

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.

owner_id
position

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

class pagetools.sections.models.TypeMixin(*args, **kwargs)[source]

Bases: Model

Pagenodes that differs only in their representation may use the same model but different node choices. The node choice is is part of the template names

class Meta[source]

Bases: object

abstract = False
node_choices: Iterable[Tuple[str, str]] = ()
node_type

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

pagetools.sections.urls module

pagetools.sections.utils module

pagetools.sections.utils.get_template_names_for_obj(obj, suffix='')[source]

pagetools.sections.views module

class pagetools.sections.views.BaseAjaxNodeView(**kwargs)[source]

Bases: BaseAjaxNodeViewMixin, BaseNodeView

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

template_suffix = '_ajax'
class pagetools.sections.views.BaseAjaxNodeViewMixin[source]

Bases: AJAXMixin

get_context_data(**kwargs)[source]
class pagetools.sections.views.BaseNodeView(**kwargs)[source]

Bases: DetailView

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

get_context_data(**kwargs)[source]

Insert the single object into the context dict.

get_object(*args, **kwargs)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_queryset(*_args, **_kwargs)[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.

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

model

alias of PageNode

template_suffix = ''
class pagetools.sections.views.PagelikeNodeView(**kwargs)[source]

Bases: SelectedMenuentriesMixin, WidgetPagelikeMixin, BaseNodeView

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

pagetools.sections.views.admin_pagenodesview(request, slug)[source]

Module contents