Exemple #1
0
class WidgyPage(WidgyPageMixin, Page):
    root_node = VersionedWidgyField(
        site=settings.WIDGY_MEZZANINE_SITE,
        verbose_name=_('widgy content'),
        root_choices=(
            'page_builder.Layout',
        ),
        # WidgyField used to have these as defaults.
        null=True,
        on_delete=models.SET_NULL,
    )

    class Meta:
        verbose_name = _('widgy page')
        verbose_name_plural = _('widgy pages')
        swappable = 'WIDGY_MEZZANINE_PAGE_MODEL'

    _base_manager = UseForRelatedFieldsSelectRelatedManager(select_related=[
        'root_node',
        'root_node__head',
        # we might not need this, if head isn't published, but we
        # probably will.
        'root_node__head__root_node',
    ])
    objects = PageManager()
Exemple #2
0
class BasePage(Orderable, Displayable):
    """
    Exists solely to store ``PageManager`` as the main manager.
    If it's defined on ``Page``, a concrete model, then each
    ``Page`` subclass loses the custom manager.
    """

    objects = PageManager()

    class Meta:
        abstract = True
Exemple #3
0
class RawPage(WidgyPageMixin, Page):
    HTML = 'text/html'
    PLAIN_TEXT = 'text/plain'
    JSON = 'application/json'
    XML = 'application/xml'

    CONTENT_TYPE_CHOICES = ((HTML, _('HTML')), (PLAIN_TEXT, _('Plain text')),
                            (JSON, _('JSON')), (XML, _('XML')))

    root_node = VersionedWidgyField(
        site=settings.WIDGY_MEZZANINE_SITE,
        verbose_name=_('widgy content'),
        root_choices=('page_builder.MainContent', ),
        # WidgyField used to have these as defaults.
        null=True,
        on_delete=models.SET_NULL,
    )

    response_content_type = models.CharField(
        verbose_name=_('Response content type'),
        max_length=255,
        choices=CONTENT_TYPE_CHOICES,
        default=HTML)

    class Meta:
        verbose_name = _('raw page')
        verbose_name_plural = _('raw pages')
        swappable = 'WIDGY_MEZZANINE_PAGE_MODEL'

    _base_manager = UseForRelatedFieldsSelectRelatedManager(select_related=[
        'root_node',
        'root_node__head',
        # we might not need this, if head isn't published, but we
        # probably will.
        'root_node__head__root_node',
    ])
    objects = PageManager()