Exemplo n.º 1
0
def page_listing_buttons(page, page_perms, is_parent=False):
    if page_perms.can_edit():
        yield PageListingButton(_('Edit'),
                                reverse('wagtailadmin_pages:edit',
                                        args=[page.id]),
                                attrs={'title': _('Edit this page')},
                                priority=10)
    if page.has_unpublished_changes:
        yield PageListingButton(_('Draft'),
                                reverse('wagtailadmin_pages:view_draft',
                                        args=[page.id]),
                                attrs={
                                    'title': _('Preview draft'),
                                    'target': '_blank'
                                },
                                priority=20)
    if page.live and page.url:
        yield PageListingButton(_('Live'),
                                page.url,
                                attrs={
                                    'target': "_blank",
                                    'title': _('View live')
                                },
                                priority=30)
    if page_perms.can_add_subpage():
        if is_parent:
            yield Button(_('Add child page'),
                         reverse('wagtailadmin_pages:add_subpage',
                                 args=[page.id]),
                         attrs={
                             'title':
                             _("Add a child page to '{0}' ".format(page.title))
                         },
                         classes={
                             'button', 'button-small', 'bicolor', 'icon',
                             'white', 'icon-plus'
                         },
                         priority=40)
        else:
            yield PageListingButton(_('Add child page'),
                                    reverse('wagtailadmin_pages:add_subpage',
                                            args=[page.id]),
                                    attrs={
                                        'title':
                                        _("Add a child page to '{0}' ".format(
                                            page.title))
                                    },
                                    priority=40)

    yield ButtonWithDropdownFromHook(
        _('More'),
        hook_name='register_page_listing_more_buttons',
        page=page,
        page_perms=page_perms,
        is_parent=is_parent,
        attrs={
            'target': '_blank',
            'title': _('View more options')
        },
        priority=50)
def page_listing_variant_buttons(page, page_perms, is_parent=False):
    """Adds page listing buttons to personalisable pages. Shows variants for
    the page (if any) and a 'Create a new variant' button.

    """
    if isinstance(page,
                  PersonalisablePageMixin) and page.get_unused_segments():
        yield ButtonWithDropdownFromHook(
            _('Variants'),
            hook_name='register_page_listing_variant_buttons',
            page=page,
            page_perms=page_perms,
            is_parent=is_parent,
            attrs={
                'target': '_blank',
                'title': _('Create a new variant')
            },
            priority=100)
Exemplo n.º 3
0
def page_listing_variant_buttons(page, page_perms, is_parent=False):
    """Adds page listing buttons to personalisable pages. Shows variants for
    the page (if any) and a 'Create a new variant' button.

    """
    personalisable_page = PersonalisablePage.objects.filter(pk=page.pk)
    segments = Segment.objects.all()

    if personalisable_page and len(segments) > 0 and not (any(
            item.segment for item in personalisable_page)):
        yield ButtonWithDropdownFromHook(
            _('Variants'),
            hook_name='register_page_listing_variant_buttons',
            page=page,
            page_perms=page_perms,
            is_parent=is_parent,
            attrs={
                'target': '_blank',
                'title': _('Create a new variant')
            },
            priority=100)
def page_listing_variant_buttons(page, page_perms, is_parent=False):
    """Adds page listing buttons to personalisable pages. Shows variants for
    the page (if any) and a 'Create a new variant' button.

    """
    if not isinstance(page, models.PersonalisablePageMixin):
        return

    metadata = page.personalisation_metadata
    if metadata.is_canonical:
        yield ButtonWithDropdownFromHook(
            _('Variants'),
            hook_name='register_page_listing_variant_buttons',
            page=page,
            page_perms=page_perms,
            is_parent=is_parent,
            attrs={
                'target': '_blank',
                'title': _('Create or edit a variant')
            },
            priority=100)