Coverage for wagtailsharing/wagtail_hooks.py: 84%

# Coverage for wagtailsharing/wagtail_hooks.py : 84%

## 19 statements 16 run 3 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from wagtail.wagtailadmin import widgets as wagtailadmin_widgets from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register from wagtail.wagtailcore import hooks from wagtailsharing.helpers import get_sharing_url from wagtailsharing.models import SharingSite class SharingSiteModelAdmin(ModelAdmin): model = SharingSite menu_icon = 'site' menu_order = 603 add_to_settings_menu = True list_display = ('site', 'hostname', 'port') modeladmin_register(SharingSiteModelAdmin) @hooks.register('register_page_listing_more_buttons') def add_sharing_link(page, page_perms, is_parent=False): sharing_url = get_sharing_url(page) if sharing_url: yield wagtailadmin_widgets.Button( 'Share', sharing_url, attrs={ 'title': _("Share latest revision of '{title}'").format( title=page.get_admin_display_title() ), }, priority=90 )