コード例 #1
0
def page_listing_buttons(page, page_perms, is_parent=False):
    if not getattr(settings, 'INTRANET_PUSH_URL', False):
        return

    if page.live and page_perms.can_publish() and getattr(
            page, 'pushable_to_intranet', False):
        yield wagtailadmin_widgets.PageListingButton('Push to intranet',
                                                     reverse(
                                                         'push_to_intranet',
                                                         args=(page.id, )),
                                                     priority=40)
コード例 #2
0
def product_requests_button(page, page_perms, is_parent=False):
    """Renders a 'requests' button on the page index showing the number
    of times the product has been requested.

    Attempts to only show such a button for valid product/variant pages
    """
    # Is this page the 'product' model?
    # It is generally safe to assume either the page will have a 'variants'
    #  member or will be an instance of longclaw.utils.ProductVariant
    if hasattr(page, 'variants') or isinstance(page, ProductVariant):
        yield widgets.PageListingButton('View Requests',
                                        reverse('productrequests_admin',
                                                kwargs={'pk': page.id}),
                                        priority=40)
コード例 #3
0
def page_listing_buttons(page, page_perms, is_parent=False):
    admin_url = 'wagtailcommerce_product_modeladmin_edit'

    # TODO if user has_permission for (django)admin product_change
    if isinstance(page.specific, ProductPage) and hasattr(page, 'product'):
        url = reverse(
            admin_url,
            args=(quote(page.product.pk), ),
            current_app='wagtailcommerce',
        )

        yield wagtailadmin_widgets.PageListingButton(
            "product",
            url,
            classes=('icon', 'icon-fa-product-hunt'),
            attrs={'title': _('Edit product in the Commerce admin ')},
            priority=100,
        )
コード例 #4
0
 def page_listing_buttons(page, page_perms, is_parent=False):
     yield wagtailadmin_widgets.PageListingButton(
         'Another useless page listing button',
         '/custom-url',
         priority=10
     )