<s> from __future__ import absolute_import , unicode_literals <EOL> from django import forms <EOL> from django . contrib . auth . models import Permission <EOL> from django . contrib . staticfiles . templatetags . staticfiles import static <EOL> from django . core . urlresolvers import reverse <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from wagtail . wagtailadmin . menu import MenuItem , SubmenuMenuItem , settings_menu <EOL> from wagtail . wagtailadmin . search import SearchArea <EOL> from wagtail . wagtailadmin . widgets import Button , ButtonWithDropdownFromHook , PageListingButton <EOL> from wagtail . wagtailcore import hooks <EOL> from wagtail . wagtailcore . permissions import collection_permission_policy <EOL> class ExplorerMenuItem ( MenuItem ) : <EOL> @ property <EOL> def media ( self ) : <EOL> return forms . Media ( js = [ static ( '<STR_LIT>' ) ] ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def register_explorer_menu_item ( ) : <EOL> return ExplorerMenuItem ( <EOL> _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' ) , <EOL> name = '<STR_LIT>' , <EOL> classnames = '<STR_LIT>' , <EOL> attrs = { '<STR_LIT>' : reverse ( '<STR_LIT>' ) } , <EOL> order = <NUM_LIT:100> ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def register_settings_menu ( ) : <EOL> return SubmenuMenuItem ( <EOL> _ ( '<STR_LIT>' ) , settings_menu , classnames = '<STR_LIT>' , order = <NUM_LIT> ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def register_permissions ( ) : <EOL> return Permission . objects . filter ( content_type__app_label = '<STR_LIT>' , codename = '<STR_LIT>' ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def register_pages_search_area ( ) : <EOL> return SearchArea ( <EOL> _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' ) , <EOL> name = '<STR_LIT>' , <EOL> classnames = '<STR_LIT>' , <EOL> order = <NUM_LIT:100> ) <EOL> class CollectionsMenuItem ( MenuItem ) : <EOL> def is_shown ( self , request ) : <EOL> return collection_permission_policy . user_has_any_permission ( <EOL> request . user , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def register_collections_menu_item ( ) : <EOL> return CollectionsMenuItem ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' ) , classnames = '<STR_LIT>' , order = <NUM_LIT> ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def page_listing_buttons ( page , page_perms , is_parent = False ) : <EOL> if page_perms . can_edit ( ) : <EOL> yield PageListingButton ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( '<STR_LIT>' ) } , priority = <NUM_LIT:10> ) <EOL> if page . has_unpublished_changes : <EOL> yield PageListingButton ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( '<STR_LIT>' ) , '<STR_LIT:target>' : '<STR_LIT>' } , priority = <NUM_LIT:20> ) <EOL> if page . live and page . url : <EOL> yield PageListingButton ( _ ( '<STR_LIT>' ) , page . url , attrs = { '<STR_LIT:target>' : "<STR_LIT>" , '<STR_LIT:title>' : _ ( '<STR_LIT>' ) } , priority = <NUM_LIT:30> ) <EOL> if page_perms . can_add_subpage ( ) : <EOL> if is_parent : <EOL> yield Button ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( "<STR_LIT>" . format ( page . title ) ) } , classes = { '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' } , priority = <NUM_LIT> ) <EOL> else : <EOL> yield PageListingButton ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( "<STR_LIT>" . format ( page . title ) ) } , priority = <NUM_LIT> ) <EOL> yield ButtonWithDropdownFromHook ( <EOL> _ ( '<STR_LIT>' ) , <EOL> hook_name = '<STR_LIT>' , <EOL> page = page , <EOL> page_perms = page_perms , <EOL> is_parent = is_parent , <EOL> attrs = { '<STR_LIT:target>' : '<STR_LIT>' , '<STR_LIT:title>' : _ ( '<STR_LIT>' ) } , priority = <NUM_LIT:50> ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def page_listing_more_buttons ( page , page_perms , is_parent = False ) : <EOL> if page_perms . can_move ( ) : <EOL> yield Button ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { "<STR_LIT:title>" : _ ( '<STR_LIT>' ) } , priority = <NUM_LIT:10> ) <EOL> if not page . is_root ( ) : <EOL> yield Button ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( '<STR_LIT>' ) } , priority = <NUM_LIT:20> ) <EOL> if page_perms . can_delete ( ) : <EOL> yield Button ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( '<STR_LIT>' ) } , priority = <NUM_LIT:30> ) <EOL> if page_perms . can_unpublish ( ) : <EOL> yield Button ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( '<STR_LIT>' ) } , priority = <NUM_LIT> ) <EOL> yield Button ( _ ( '<STR_LIT>' ) , reverse ( '<STR_LIT>' , args = [ page . id ] ) , <EOL> attrs = { '<STR_LIT:title>' : _ ( "<STR_LIT>" ) } , priority = <NUM_LIT:50> ) </s>
