from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register) from .models import BlogPage """ Funder: a Django/Wagtail based web application to facilitate online donations. Copyright (C) 2016 R. Dohmen <*****@*****.**> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ class BlogPageModelAdmin(ModelAdmin): menu_label = 'Blog' menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd), just after Explorer model = BlogPage menu_icon = 'doc-full-inverse' # change as required list_display = ('title', 'teaser', 'live') search_fields = ('title',) modeladmin_register(BlogPageModelAdmin)
MultiFieldPanel([ FieldPanel('diffusion'), FieldPanel('sound'), FieldPanel('track'), ], heading = _('Related objects')), ] # Missing: Port, Station, Track class AdvancedAdminGroup(ModelAdminGroup): menu_label = _("Advanced") menu_icon = 'plus-inverse' items = (ProgramAdmin, DiffusionAdmin, ScheduleAdmin, StreamAdmin, LogAdmin) modeladmin_register(AdvancedAdminGroup) class CommentAdmin(ModelAdmin): model = models.Comment menu_label = _('Comments') menu_icon = 'pick' menu_order = 300 list_display = ('published', 'publication', 'author', 'date', 'content') list_filter = ('date', 'published') search_fields = ('author', 'content', 'publication__title') modeladmin_register(CommentAdmin) class SoundAdmin(ModelAdmin): model = aircox.models.Sound
from django.conf import settings from django.conf.urls import include, url from django.utils.html import format_html_join from wagtail.contrib.modeladmin.options import modeladmin_register from wagtail.core import hooks from molo.surveys.models import MoloSurveyPage, SurveyTermsConditions from molo.surveys import admin_urls from molo.core.models import ArticlePage from .admin import SegmentUserGroupAdmin modeladmin_register(SegmentUserGroupAdmin) @hooks.register('insert_global_admin_js') def global_admin_js(): js_files = [ 'js/survey-admin.js', ] js_includes = format_html_join( '\n', '<script src="{0}{1}"></script>', ((settings.STATIC_URL, filename) for filename in js_files) ) return js_includes @hooks.register('after_copy_page')
from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register ) from .models import Vassal from .admin import VassalFields class VassalModelAdmin(VassalFields, ModelAdmin): model = Vassal menu_icon = 'cogs' menu_order = 800 add_to_settings_menu = True modeladmin_register(VassalModelAdmin)
panels = [ FieldPanel('last_name'), FieldPanel('phone_number'), FieldPanel('address'), ] class EventsAdminGroup(ModelAdminGroup): menu_label = "Events" items = (EventPageAdmin, SingleEventPageAdmin, VenuePageAdmin) menu_order = 500 class BusinessChildAdmin(ModelAdmin): model = BusinessChild # having "Business Child" permanently in the menu confuses tests for the 'add page' view menu_label = "BusinessSprog" modeladmin_register(AuthorModelAdmin) modeladmin_register(BookModelAdmin) modeladmin_register(TokenModelAdmin) modeladmin_register(PublisherModelAdmin) modeladmin_register(EventsAdminGroup) modeladmin_register(BusinessChildAdmin) modeladmin_register(PersonAdmin) modeladmin_register(FriendAdmin) modeladmin_register(VisitorAdmin) modeladmin_register(ContributorAdmin)
return response @hooks.register('before_serve_shared_page') def before_serve_shared_page(page, request, args, kwargs): request.show_draft_megamenu = True class MegaMenuModelAdmin(ModelAdmin): model = MegaMenuItem menu_label = 'Mega Menu' menu_icon = 'cog' list_display = ('link_text', 'order') modeladmin_register(MegaMenuModelAdmin) @receiver(post_save, sender=MegaMenuItem) def clear_mega_menu_cache(sender, instance, **kwargs): from django.core.cache import caches caches['default_fragment_cache'].delete('mega_menu') def get_resource_tags(): tag_list = [] for resource in Resource.objects.all(): for tag in resource.tags.all(): tuple = (tag.slug, tag.name) if tuple not in tag_list:
class OrderModelAdmin(ModelAdmin): model = Order menu_label = 'Orders' # ditch this to use verbose_name_plural from model menu_icon = 'snippet' # change as required list_display = ('order_nr', 'anonymous', 'billing_name', 'billing_company', 'billing_email', 'billing_date', 'paid_date', 'is_paid') list_filter = ('billing_name', 'billing_company', 'anonymous') search_fields = ('title',) # class MySnippetModelAdmin(ModelAdmin): # model = MySnippetModel # menu_label = 'Snippet Model' # ditch this to use verbose_name_plural from model # menu_icon = 'snippet' # change as required # list_display = ('title', 'example_field2', 'example_field3') # list_filter = (example_field2', 'example_field3') # search_fields = ('title',) class MyModelAdminGroup(ModelAdminGroup): menu_label = 'Fundraiser' menu_icon = 'folder-open-inverse' # change as required menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) items = (OrderModelAdmin, ProductPageModelAdmin, ProjectPageModelAdmin) # When using a ModelAdminGroup class to group several ModelAdmin classes together, # you only need to register the ModelAdminGroup class with Wagtail: modeladmin_register(MyModelAdminGroup)
from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register) from django.utils.translation import ugettext as _ from .models import DefinitionPage class DefinitionPageModelAdmin(ModelAdmin): model = DefinitionPage menu_label = 'Definitions' # ditch this to use verbose_name_plural from model menu_icon = 'help definition' # change as required menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) list_display = ('title', ) list_filter = ('live', ) search_fields = ('title',) # Now you just need to register your customised ModelAdmin class with Wagtail modeladmin_register(DefinitionPageModelAdmin)
from .forms import StructureNodeForm from .admin import StructureNodeAdmin from wagtail.contrib.modeladmin.options import modeladmin_register modeladmin_register(StructureNodeAdmin)
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register from events.models import Venue class VenueModelAdmin(ModelAdmin): model = Venue menu_label = 'Venues' menu_icon = 'site' menu_order = 270 list_display = ('name_en', 'name_be', 'name_ru') search_fields = ('name_en', 'name_be', 'name_ru') modeladmin_register(VenueModelAdmin)
class EventsAdminGroup(ModelAdminGroup): menu_label = "Events" items = (EventPageAdmin, SingleEventPageAdmin, VenuePageAdmin) menu_order = 500 class BusinessChildAdmin(ModelAdmin): model = BusinessChild # having "Business Child" permanently in the menu confuses tests for the 'add page' view menu_label = "BusinessSprog" class RelatedLinkAdmin(ModelAdmin): model = RelatedLink menu_label = "Related Links" modeladmin_register(AuthorModelAdmin) modeladmin_register(BookModelAdmin) modeladmin_register(TokenModelAdmin) modeladmin_register(PublisherModelAdmin) modeladmin_register(EventsAdminGroup) modeladmin_register(BusinessChildAdmin) modeladmin_register(PersonAdmin) modeladmin_register(FriendAdmin) modeladmin_register(VisitorAdmin) modeladmin_register(ContributorAdmin) modeladmin_register(RelatedLinkAdmin)
@hooks.register('before_edit_page') def stashRequest(request, page): if isinstance(page, CalendarPage) and CalendarPageForm.importHandler: page.__joyous_edit_request = request return None CalendarPageForm.registerImportHandler(ICalHandler()) CalendarPageForm.registerExportHandler(ICalHandler()) # ------------------------------------------------------------------------------ class EventCategoryAdmin(ModelAdmin): model = EventCategory menu_icon = 'tag' menu_label = 'Event Categories' menu_order = 1200 add_to_settings_menu = True exclude_from_explorer = False list_display = ('code', 'name') list_filter = () search_fields = ('name', ) modeladmin_register(EventCategoryAdmin) # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
class AreaViewAdmin(ModelAdmin): create_template_name = 'wagtailadmin/common_template/create.html' edit_template_name = 'wagtailadmin/common_template/edit.html' model = Area menu_icon = "group" menu_order = 290 add_to_settings_menu = True list_display = ( "name", "id", "created", ) modeladmin_register(AreaViewAdmin) class SubjectViewAdmin(ModelAdmin): create_template_name = 'wagtailadmin/common_template/create.html' edit_template_name = 'wagtailadmin/common_template/edit.html' model = Subject menu_icon = "group" menu_order = 290 add_to_settings_menu = True exclude_from_explorer = False list_display = ( "name", "area", "id", "created",
def role_and_production(self, obj): # pylint: disable=no-self-use if obj.production and obj.role: return format_html( '{} at <a href="{}">{}</a>', obj.role, reverse('wagtailadmin_pages:edit', args=(obj.production.id,)), obj.production ) elif obj.production: return format_html( '<a href="{}">{}</a>', reverse('wagtailadmin_pages:edit', args=(obj.production.id,)), obj.production ) elif obj.role: return obj.role else: return "" role_and_production.admin_order_field = '-production' def full_name(self, obj): # pylint: disable=no-self-use return "%s %s" % ( obj.first_name, obj.last_name ) full_name.short_description = 'name' full_name.admin_order_field = 'last_name' modeladmin_register(PeopleAdmin)
class DatetimeListFilter(admin.SimpleListFilter): title = 'Zeitpunkt' parameter_name = 'start_datetime' def lookups(self, request, model_admin): return ( ('upcoming', 'anstehend'), ('expired', 'abgelaufen') ) def queryset(self, request, queryset): today = datetime.date.today() if self.value() == 'upcoming': return EventPage.objects.upcoming() if self.value() == 'expired': return EventPage.objects.expired() class EventPageModelAdmin(ModelAdmin): model = EventPage menu_icon = 'date' menu_order = 200 add_to_settings_menu = False list_display = ('title', 'start_datetime', 'location', 'related_group') list_filter = (DatetimeListFilter, 'related_group') search_fields = ('title', 'content', 'location') #ordering = ('start_datetime',) modeladmin_register(EventPageModelAdmin)
import datetime from django.contrib import admin from django.db.models import Q from wagtail.contrib.modeladmin.options import ( ModelAdmin, ModelAdminGroup, modeladmin_register) from .models import PersonPage class PersonPageModelAdmin(ModelAdmin): model = PersonPage menu_icon = 'user' menu_order = 201 add_to_settings_menu = False list_display = ('title', 'role') list_filter = ('role',) search_fields = ('title',) ordering = ('title',) modeladmin_register(PersonPageModelAdmin)
from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register) from .models import GenreClass class GenreAdmin(ModelAdmin): model = GenreClass menu_label = 'Genres' # ditch this to use verbose_name_plural from model menu_icon = 'fa-list-alt' # change as required menu_order = 300 add_to_settings_menu = False # or True to add your model to the Settings sub-menu list_display = ('title', 'subgenre_list') search_fields = ('title',) # class GenreAdminGroup(ModelAdminGroup): # menu_label = 'Genres' # menu_icon = 'fa-music' # change as required # menu_order = 300 # will put in 3rd place (000 being 1st, 100 2nd) # items = (GenreAdmin) modeladmin_register(GenreAdmin)
url(self.url_helper.get_action_url_pattern('badge'), self.badge_view, name=self.url_helper.get_action_url_name('badge')), url(self.url_helper.get_action_url_pattern('inactivate'), self.inactivate_view, name=self.url_helper.get_action_url_name('inactivate')), ) return urls class WorkgroupContainerMA(HiddenModelAdmin): model = WorkGroupContainer exclude_from_explorer = False # True modeladmin_register(WorkgroupContainerMA) class ProjectContainerMA(HiddenModelAdmin): model = ProjectContainer exclude_from_explorer = False #True modeladmin_register(ProjectContainerMA) class ListOfProjectsPageMA(HiddenModelAdmin): model = ListOfProjectsPage exclude_from_explorer = False #True
model = SignUpFormPageResponse menu_label = 'Sign-Up Form Page Submissions' menu_icon = 'date' menu_order = 600 add_to_settings_menu = False list_display = ('date', 'email') class SubmissionsModelAdminGroup(ModelAdminGroup): menu_label = 'Form Submissions' menu_icon = 'folder-open-inverse' # change as required menu_order = 600 items = (SignUpFormPageResponseModelAdmin, GoogleAdGrantApplicationModelAdmin) modeladmin_register(SubmissionsModelAdminGroup) @hooks.register('before_serve_document', order=100) def serve_document_from_s3(document, request): # Skip this hook if not using django-storages boto3 backend. if not issubclass(get_storage_class(), S3Boto3Storage): return # Send document_served signal. document_served.send(sender=get_document_model(), instance=document, request=request) # Get direct S3 link. file_url = document.file.url
from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register) from .models import Artist class ArtistAdmin(ModelAdmin): model = Artist menu_label = 'Artists' # ditch this to use verbose_name_plural from model menu_icon = 'fa-bolt' # change as required menu_order = 300 # will put in 3rd place (000 being 1st, 100 2nd) add_to_settings_menu = False # or True to add your model to the Settings sub-menu list_display = ('title', 'decade_formed', 'genre', 'artist_image') # https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display list_filter = ( 'date_formed', 'artist_genre_relationship__genres' ) search_fields = ('title',) modeladmin_register(ArtistAdmin) # Note Andy Babic has now added exceptional documentation about ModelAdmin # at http://docs.wagtail.io/en/latest/reference/contrib/modeladmin/index.html
def register_article_question_results_admin_view_url(): return [ url(r'reactionquestion/(?P<article>\d+)/results/summary/$', ReactionQuestionSummaryAdminView.as_view(), name='reaction-question-article-results-admin'), ] class ReactionQuestionsGroup(ModelAdminGroup): menu_label = 'ReactionQuestions' menu_icon = 'folder-open-inverse' menu_order = 500 items = (ReactionQuestionsSummaryModelAdmin, ReactionQuestionsModelAdmin) modeladmin_register(ReactionQuestionsGroup) @hooks.register('construct_main_menu') def show_reactionquestions_response_for_users_have_access(request, menu_items): if not request.user.has_perm('core.can_view_response'): menu_items[:] = [ item for item in menu_items if item.name != 'reactionquestions'] modeladmin_register(AdminViewGroup) @hooks.register('construct_explorer_page_queryset') def show_main_language_only(parent_page, pages, request): main_language = Languages.for_site(request.site).languages.filter(
menu_label = 'Session' list_display = ('title', 'date') search_display = ('title', 'date') class GameGroupModelAdminGroup(ModelAdminGroup): menu_label = 'Groups' menu_icon = 'folder-open-inverse' items = (GroupModelAdmin, SessionModelAdmin, VenueModelAdmin) class BlogArticleModelAdmin(ModelAdmin): model = BlogArticle menu_label = 'Blog Post' list_display = ('title', 'date') search_display = ('title', 'date') modeladmin_register(GameModelAdmin) modeladmin_register(GameGroupModelAdminGroup) modeladmin_register(BlogArticleModelAdmin) @hooks.register('insert_editor_js') def selectize_js(): js_files = [ 'js/admin/selectize.js', 'js/admin/admin.js' ] js_includes = format_html_join('\n', '<script src="{0}{1}"></script>', ((settings.STATIC_URL, filename) for filename in js_files) ) return js_includes + format_html(
from wagtail.core import hooks from wagtail.contrib.modeladmin.options import modeladmin_register from wagtailmenus.conf import settings from wagtailmenus.modeladmin import ( # noqa MainMenuAdmin, FlatMenuAdmin, FlatMenuButtonHelper ) if settings.MAIN_MENUS_EDITABLE_IN_WAGTAILADMIN: modeladmin_register(settings.objects.MAIN_MENUS_MODELADMIN_CLASS) if settings.FLAT_MENUS_EDITABLE_IN_WAGTAILADMIN: modeladmin_register(settings.objects.FLAT_MENUS_MODELADMIN_CLASS) @hooks.register('before_serve_page') def wagtailmenu_params_helper(page, request, serve_args, serve_kwargs): section_root = request.site.root_page.get_descendants().ancestor_of( page, inclusive=True ).filter(depth__exact=settings.SECTION_ROOT_DEPTH).first() if section_root: section_root = section_root.specific ancestor_ids = page.get_ancestors().filter( depth__gte=settings.SECTION_ROOT_DEPTH ).values_list('id', flat=True) request.META.update({ 'WAGTAILMENUS_CURRENT_SECTION_ROOT': section_root, 'WAGTAILMENUS_CURRENT_PAGE': page, 'WAGTAILMENUS_CURRENT_PAGE_ANCESTOR_IDS': ancestor_ids, })
from wagtail.contrib.modeladmin.options import modeladmin_register from .admin import TaxonomyModelAdminGroup modeladmin_register(TaxonomyModelAdminGroup)
# Allows Glossary administration from Wagtail # # in this module (name must be wagtail_hooks.py for auto-discovery by wagtail app) # We register TermModelAdmin in wagtail for Term django-term app's Model # see http://docs.wagtail.io/en/v2.0/reference/contrib/modeladmin/index.html from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register from terms.models import Term class TermModelAdmin(ModelAdmin): model = Term menu_label = 'Glossary' # ditch this to use verbose_name_plural from model menu_icon = 'openquote' # change as required menu_order = 600 # will put in 7th place (000 being 1st, 100 2nd) add_to_settings_menu = False # or True to add your model to the Settings sub-menu exclude_from_explorer = False # or True to exclude pages of this type from Wagtail's explorer view list_display = ('name', 'definition', 'url') list_filter = None # ('case_sensitive', 'url') search_fields = ('name',) ordering = ('name',) # Now you just need to register your customised ModelAdmin class with Wagtail modeladmin_register(TermModelAdmin)
'src': attribute_rule(ALLTAGS), 'video': attribute_rule(ALLTAGS), 'div': attribute_rule(ALLTAGS), 'noscript': attribute_rule(ALLTAGS), 'param': attribute_rule(ALLTAGS), } class PostModelAdmin(ModelAdmin): model = Post menu_label = 'Blog' # ditch this to use verbose_name_plural from model menu_icon = 'date' # change as required menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) add_to_settings_menu = False # or True to add your model to the Settings sub-menu list_display = ('title',) search_fields = ('title','body_en','body_ar') # Now you just need to register your customised ModelAdmin class with Wagtail modeladmin_register(PostModelAdmin) class PageModelAdmin(ModelAdmin): model = Page menu_label = 'Page' # ditch this to use verbose_name_plural from model menu_icon = 'date' # change as required menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) add_to_settings_menu = False # or True to add your model to the Settings sub-menu list_display = ('title',) search_fields = ('title','body_en','body_ar') # Now you just need to register your customised ModelAdmin class with Wagtail modeladmin_register(PageModelAdmin)
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register, ModelAdminGroup from .models import DevelopmentMethod, DevelopmentPhase, UserRole class UserRoleAdmin(ModelAdmin): model = UserRole menu_icon = 'user' class DevelopmentMethodAdmin(ModelAdmin): model = DevelopmentMethod class DevelopmentPhaseAdmin(ModelAdmin): model = DevelopmentPhase list_display = ('name', 'method') class KehmetAdminGroup(ModelAdminGroup): label = "Kehmet" items = (UserRoleAdmin, DevelopmentMethodAdmin, DevelopmentPhaseAdmin) modeladmin_register(KehmetAdminGroup)
add_to_settings_menu = True def get_form_view_extra_css(self): return ['wagtailmenus/css/menu-edit.css'] + self.form_view_extra_css def get_admin_urls_for_registration(self): return ( url(self.url_helper.get_action_url_pattern('index'), self.index_view, name=self.url_helper.get_action_url_name('index')), url(self.url_helper.get_action_url_pattern('edit'), self.edit_view, name=self.url_helper.get_action_url_name('edit')), ) modeladmin_register(MainMenuAdmin) class FlatMenuButtonHelper(ButtonHelper): def copy_button(self, pk, classnames_add=[], classnames_exclude=[]): cn = self.finalise_classname(classnames_add, classnames_exclude) return { 'url': self.url_helper.get_action_url('copy', quote(pk)), 'label': _('Copy'), 'classname': cn, 'title': _('Copy this %s') % self.verbose_name, } def get_buttons_for_obj(self, obj, exclude=[], classnames_add=[], classnames_exclude=[]):
from .models import Token from .views import TokenCreateView @hooks.register('register_page_listing_more_buttons') def page_listing_button_link_token(page, page_perms, is_parent): if not isinstance(page, (Timeline, Gallery)): return token = Token.objects.singleton() if token: yield Button( _('Token link'), '{url}?token={key}'.format(url=page.full_url, key=token.key), attrs={'title': _('Copy this link address to share it.')}, priority=0 ) class TokenAdmin(ModelAdmin): model = Token menu_label = _('Token') menu_icon = 'password' add_to_settings_menu = True list_display = ('key', 'created') ordering = ('-created',) create_view_class = TokenCreateView modeladmin_register(TokenAdmin)
model = EventPage list_display = ('title', 'date_from', 'audience') list_filter = ('audience', ) search_fields = ('title', ) inspect_view_enabled = True inspect_view_fields_exclude = ('feed_image', ) class SingleEventPageAdmin(EventPageAdmin): model = SingleEventPage class EventsAdminGroup(ModelAdminGroup): menu_label = "Events" items = (EventPageAdmin, SingleEventPageAdmin) menu_order = 500 class BusinessChildAdmin(ModelAdmin): model = BusinessChild # having "Business Child" permanently in the menu confuses tests for the 'add page' view menu_label = "BusinessSprog" modeladmin_register(AuthorModelAdmin) modeladmin_register(BookModelAdmin) modeladmin_register(TokenModelAdmin) modeladmin_register(PublisherModelAdmin) modeladmin_register(EventsAdminGroup) modeladmin_register(BusinessChildAdmin)
from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register) from .models import FormQuestion class MyPageModelAdmin(ModelAdmin): model = FormQuestion menu_label = 'Page Model' # ditch this to use verbose_name_plural from model menu_icon = 'date' # change as required menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) add_to_settings_menu = False # or True to add your model to the Settings sub-menu list_display = ('title', 'live') list_filter = ('live',) search_fields = ('title',) # Now you just need to register your customised ModelAdmin class with Wagtail modeladmin_register(MyPageModelAdmin)
from django.utils.translation import ugettext_lazy as _ from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register from .models import Person class PersonAdmin(ModelAdmin): model = Person menu_label = _("People") menu_icon = 'user' modeladmin_register(PersonAdmin)
from .models import FooterLinkSection, Indicator class IndicatorAdmin(ModelAdmin): model = Indicator menu_icon = 'user' class FooterLinkSectionAdmin(ModelAdmin): model = FooterLinkSection menu_icon = 'redirect' class DigiHelAdminGroup(ModelAdminGroup): label = "DigiHel" items = (IndicatorAdmin, FooterLinkSectionAdmin) modeladmin_register(DigiHelAdminGroup) # Enable editing of raw HTML @hooks.register('insert_editor_js') def enable_source_editing(): return format_html( """ <script> registerHalloPlugin('hallohtml'); </script> """ )
from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register) from .models import OrganizationPage class OrganizationPageModelAdmin(ModelAdmin): model = OrganizationPage menu_icon = 'group' # change as required menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) list_display = ('title', ) list_filter = ('live', ) search_fields = ('title',) # Now you just need to register your customised ModelAdmin class with Wagtail modeladmin_register(OrganizationPageModelAdmin)
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register from unusualbusiness.howtos.models import HowToPage class HowToPageModelAdmin(ModelAdmin): model = HowToPage menu_label = "Knowledge pools" # ditch this to use verbose_name_plural from model menu_icon = "radio-empty howtos" # change as required menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) list_display = ("title",) list_filter = ("live",) search_fields = ("title",) # Now you just need to register your customised ModelAdmin class with Wagtail modeladmin_register(HowToPageModelAdmin)
@hooks.register('before_serve_page') def serve_latest_draft_page(page, request, args, kwargs): if page.pk in settings.SERVE_LATEST_DRAFT_PAGES: latest_draft = page.get_latest_revision_as_page() response = latest_draft.serve(request, *args, **kwargs) response['Serving-Wagtail-Draft'] = '1' return response @hooks.register('before_serve_shared_page') def before_serve_shared_page(page, request, args, kwargs): request.show_draft_megamenu = True class MegaMenuModelAdmin(ModelAdmin): model = MegaMenuItem menu_label = 'Mega Menu' menu_icon = 'cog' list_display = ('link_text', 'order') modeladmin_register(MegaMenuModelAdmin) @receiver(post_save, sender=MegaMenuItem) def clear_mega_menu_cache(sender, instance, **kwargs): from django.core.cache import caches caches['default_fragment_cache'].delete('mega_menu')
if ADD_EDITOR_OVERRIDE_STYLES: return ['wagtailmenus/css/menu-edit.css'] return [] def get_admin_urls_for_registration(self): return ( url(self.url_helper.get_action_url_pattern('index'), self.index_view, name=self.url_helper.get_action_url_name('index')), url(self.url_helper.get_action_url_pattern('edit'), self.edit_view, name=self.url_helper.get_action_url_name('edit')), ) modeladmin_register(MainMenuAdmin) class FlatMenuButtonHelper(ButtonHelper): def copy_button(self, pk, classnames_add=[], classnames_exclude=[]): cn = self.finalise_classname(classnames_add, classnames_exclude) return { 'url': self.url_helper.get_action_url('copy', quote(pk)), 'label': _('Copy'), 'classname': cn, 'title': _('Copy this %s') % self.verbose_name, } def get_buttons_for_obj(self, obj, exclude=[],