diff --git a/czech_inspirational/models.py b/czech_inspirational/models.py index d23c5679d35ee6daf61d1e0895ffecaa587093ff..51c81fc7dba6870836975415034aefe6ba2e7a36 100644 --- a/czech_inspirational/models.py +++ b/czech_inspirational/models.py @@ -17,7 +17,7 @@ from wagtailmetadata.models import MetadataPageMixin from shared.models import SubpageMixin from shared.utils import subscribe_to_newsletter -from tuning import help +from tuning import admin_help from uniweb.constants import RICH_TEXT_FEATURES @@ -43,7 +43,7 @@ class CzechInspirationalHomePage(Page, MetadataPageMixin): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), + HelpPanel(admin_help.build(admin_help.IMPORTANT_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -125,7 +125,11 @@ class CzechInspirationalChaptersPage(Page, SubpageMixin, MetadataPageMixin): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), + HelpPanel( + admin_help.build( + admin_help.NO_SEO_TITLE, admin_help.NO_SEARCH_IMAGE + ) + ), ], gettext_lazy("Common page configuration"), ), @@ -188,7 +192,11 @@ class CzechInspirationalChapterPage(Page, SubpageMixin, MetadataPageMixin): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), + HelpPanel( + admin_help.build( + admin_help.NO_SEO_TITLE, admin_help.NO_SEARCH_IMAGE + ) + ), ], gettext_lazy("Common page configuration"), ), @@ -242,7 +250,11 @@ class CzechInspirationalDownloadPage(Page, SubpageMixin, MetadataPageMixin): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), + HelpPanel( + admin_help.build( + admin_help.NO_SEO_TITLE, admin_help.NO_SEARCH_IMAGE + ) + ), ], gettext_lazy("Common page configuration"), ), diff --git a/district/models.py b/district/models.py index a98927ece6618edb10b7076be391848a8caffcd7..9c9108667fcd0adbdfec3eada9117e556b2c04ca 100644 --- a/district/models.py +++ b/district/models.py @@ -9,7 +9,6 @@ from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey from taggit.models import Tag, TaggedItemBase from wagtail.admin.edit_handlers import ( - CommentPanel, FieldPanel, HelpPanel, MultiFieldPanel, @@ -28,6 +27,8 @@ from wagtailmetadata.models import MetadataPageMixin from calendar_utils.models import CalendarMixin from shared.models import ArticleMixin, MenuMixin, SubpageMixin +from shared.utils import make_promote_panels +from tuning import admin_help from uniweb.constants import RICH_TEXT_FEATURES from . import blocks @@ -182,6 +183,8 @@ class DistrictHomePage(MenuMixin, MetadataPageMixin, CalendarMixin, Page): FieldPanel("show_calendar_on_hp"), ] + promote_panels = make_promote_panels(admin_help.build(admin_help.IMPORTANT_TITLE)) + settings_panels = [ ImageChooserPanel("custom_logo"), FieldPanel("matomo_id"), @@ -229,14 +232,14 @@ class DistrictHomePage(MenuMixin, MetadataPageMixin, CalendarMixin, Page): gettext_lazy("Nastavení lišty s kalendářem a mapou"), ), ImageChooserPanel("fallback_image"), - CommentPanel(), ] ### EDIT HANDLERS + edit_handler = TabbedInterface( [ ObjectList(content_panels, heading="Obsah"), - ObjectList(MetadataPageMixin.promote_panels, heading="Propagovat"), + ObjectList(promote_panels, heading="Propagovat"), ObjectList(settings_panels, heading="Nastavení"), ObjectList(MenuMixin.menu_panels, heading="Menu"), ] @@ -341,6 +344,8 @@ class DistrictArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Page): FieldPanel("tags"), ] + promote_panels = make_promote_panels() + ### RELATIONS parent_page_types = ["district.DistrictArticlesPage"] @@ -376,7 +381,7 @@ class DistrictArticlesPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("max_items"), ] - settings_panels = [CommentPanel()] + promote_panels = make_promote_panels() import_panels = [ MultiFieldPanel( @@ -405,7 +410,7 @@ class DistrictArticlesPage(SubpageMixin, MetadataPageMixin, Page): edit_handler = TabbedInterface( [ ObjectList(content_panels, heading="Obsah"), - ObjectList(settings_panels, heading="Nastavení"), + ObjectList(promote_panels, heading="Propagovat"), ObjectList(import_panels, heading="Import"), ] ) @@ -451,6 +456,10 @@ class DistrictContactPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("text"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["district.DistrictHomePage"] @@ -465,7 +474,9 @@ class DistrictContactPage(SubpageMixin, MetadataPageMixin, Page): class DistrictTagsPage(SubpageMixin, MetadataPageMixin, Page): ### PANELS - settings_panels = [CommentPanel()] + promote_panels = make_promote_panels() + + settings_panels = [] ### RELATIONS @@ -695,7 +706,9 @@ class DistrictPeoplePage(SubpageMixin, MetadataPageMixin, Page): content_panels = Page.content_panels + [StreamFieldPanel("content")] - settings_panels = [CommentPanel()] + promote_panels = make_promote_panels() + + settings_panels = [] ### RELATIONS @@ -714,9 +727,11 @@ class DistrictElectionBasePage(SubpageMixin, MetadataPageMixin, Page): ### PANELS - content_panels = Page.content_panels + [ - FieldPanel("text"), - ] + content_panels = Page.content_panels + [FieldPanel("text")] + + promote_panels = make_promote_panels() + + settings_panels = [] ### RELATIONS @@ -840,6 +855,10 @@ class DistrictProgramPage(SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["district.DistrictHomePage"] @@ -889,6 +908,10 @@ class DistrictCenterPage(CalendarMixin, SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("sidebar_content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["district.DistrictHomePage"] @@ -940,6 +963,10 @@ class DistrictCrossroadPage(SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["district.DistrictHomePage"] @@ -984,6 +1011,10 @@ class DistrictCustomPage(SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["district.DistrictHomePage", "district.DistrictCrossroadPage"] diff --git a/districts/models.py b/districts/models.py index 761e64c11721c3cf765bf2b8b6f7dbd02bc731eb..1d21e97e6020aa6936e754d456701a38a08c67ae 100644 --- a/districts/models.py +++ b/districts/models.py @@ -10,7 +10,7 @@ from wagtail.core.models import Page from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin -from tuning import help +from tuning import admin_help class DistrictsHomePage(MetadataPageMixin, Page): @@ -28,7 +28,7 @@ class DistrictsHomePage(MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), + HelpPanel(admin_help.build(admin_help.IMPORTANT_TITLE)), ], gettext_lazy("Common page configuration"), ), diff --git a/donate/models.py b/donate/models.py index ab3aee8e6df3aad5bbfd3c4b75ca30cf001f1db7..f340fc05de2dfb9cb128ead2fadce730390e4316 100644 --- a/donate/models.py +++ b/donate/models.py @@ -6,18 +6,14 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.db import models from django.http import HttpResponseRedirect from django.shortcuts import redirect -from django.utils.translation import gettext_lazy from modelcluster.fields import ParentalKey from wagtail.admin.edit_handlers import ( - CommentPanel, FieldPanel, - HelpPanel, InlinePanel, MultiFieldPanel, PublishingPanel, StreamFieldPanel, ) -from wagtail.core import blocks from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Orderable, Page from wagtail.images.blocks import ImageChooserBlock @@ -25,8 +21,8 @@ from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin from shared.models import SubpageMixin -from shared.utils import get_subpage_url -from tuning import help +from shared.utils import get_subpage_url, make_promote_panels +from tuning import admin_help from .forms import DonateForm from .utils import get_donated_amount_from_api @@ -138,17 +134,7 @@ class DonateHomePage(DonateFormMixin, DonateFormAmountsMixin, Page, MetadataPage ), ] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels(admin_help.build(admin_help.IMPORTANT_TITLE)) settings_panels = [ MultiFieldPanel( @@ -171,7 +157,6 @@ class DonateHomePage(DonateFormMixin, DonateFormAmountsMixin, Page, MetadataPage ], "nastavení darů", ), - CommentPanel(), ] ### RELATIONS @@ -235,20 +220,9 @@ class DonateHomePage(DonateFormMixin, DonateFormAmountsMixin, Page, MetadataPage class DonateRegionIndexPage(Page, SubpageMixin, MetadataPageMixin): ### PANELS - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() - settings_panels = [CommentPanel()] + settings_panels = [] ### RELATIONS @@ -284,24 +258,13 @@ class DonateRegionPage( FieldPanel("body", classname="full"), ] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel( - help.build( - "Pokud není zadán <strong>Titulek stránky</strong>, použije " - "se <strong>Hlavní nadpis</strong> (tab obsah).", - help.NO_SEARCH_IMAGE, - ) - ), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels( + admin_help.build( + "Pokud není zadán <strong>Titulek stránky</strong>, použije " + "se <strong>Hlavní nadpis</strong> (tab obsah).", + admin_help.NO_SEARCH_IMAGE, + ) + ) settings_panels = [ MultiFieldPanel( @@ -314,7 +277,6 @@ class DonateRegionPage( ], "nastavení darů", ), - CommentPanel(), ] ### RELATIONS @@ -345,20 +307,9 @@ class DonateRegionPage( class DonateProjectIndexPage(Page, SubpageMixin, MetadataPageMixin): ### PANELS - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() - settings_panels = [CommentPanel()] + settings_panels = [] ### RELATIONS @@ -449,23 +400,14 @@ class DonateProjectPage( StreamFieldPanel("gallery"), ] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - HelpPanel( - help.build( - "Pokud není zadán <strong>Titulek stránky</strong>, použije " - "se „Podpoř projekt <strong>Název</strong>“ (tab obsah).", - help.NO_DESCRIPTION_USE_PEREX, - ) - ), - ], - gettext_lazy("Common page configuration"), + promote_panels = make_promote_panels( + admin_help.build( + "Pokud není zadán <strong>Titulek stránky</strong>, použije " + "se „Podpoř projekt <strong>Název</strong>“ (tab obsah).", + admin_help.NO_DESCRIPTION_USE_PEREX, ), - ] + search_image=False, + ) settings_panels = [ PublishingPanel(), @@ -483,7 +425,6 @@ class DonateProjectPage( "nastavení darů", ), FieldPanel("coalition_design"), - CommentPanel(), ] ### RELATIONS @@ -561,24 +502,11 @@ class DonateTextPage(Page, SubpageMixin, MetadataPageMixin): ### PANELS - content_panels = Page.content_panels + [ - FieldPanel("body", classname="full"), - ] + content_panels = Page.content_panels + [FieldPanel("body", classname="full")] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() - settings_panels = [CommentPanel()] + settings_panels = [] ### RELATIONS @@ -601,24 +529,11 @@ class DonateInfoPage(DonateFormMixin, Page, SubpageMixin, MetadataPageMixin): ### PANELS - content_panels = Page.content_panels + [ - FieldPanel("body", classname="full"), - ] + content_panels = Page.content_panels + [FieldPanel("body", classname="full")] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() - settings_panels = [CommentPanel()] + settings_panels = [] ### RELATIONS @@ -680,20 +595,9 @@ class DonateTargetedDonationsPage( MultiFieldPanel([InlinePanel("targeted_donations")], "adresné dary"), ] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() - settings_panels = [CommentPanel()] + settings_panels = [] ### RELATIONS diff --git a/elections2021/models.py b/elections2021/models.py index cb5c5b012055481198053bf4351b796f2a89bfea..70a887db307715d73684226ec66075987265b77c 100644 --- a/elections2021/models.py +++ b/elections2021/models.py @@ -39,7 +39,7 @@ from wagtailmetadata.models import MetadataPageMixin from calendar_utils.models import CalendarMixin from shared.models import ArticleMixin, SubpageMixin from shared.utils import get_subpage_url, subscribe_to_newsletter -from tuning import help +from tuning import admin_help from .constants import ( AGE_30_49, @@ -304,7 +304,7 @@ class Elections2021HomePage(MetadataPageMixin, RoutablePageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), + HelpPanel(admin_help.build(admin_help.IMPORTANT_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -564,7 +564,11 @@ class Elections2021ArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Pa FieldPanel("slug"), FieldPanel("seo_title"), FieldPanel("search_description"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_DESCRIPTION_USE_PEREX)), + HelpPanel( + admin_help.build( + admin_help.NO_SEO_TITLE, admin_help.NO_DESCRIPTION_USE_PEREX + ) + ), ], gettext_lazy("Common page configuration"), ), @@ -628,7 +632,9 @@ class Elections2021ArticlesPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -686,7 +692,9 @@ class Elections2021CandidatesListPage( FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -764,7 +772,9 @@ class Elections2021CandidatesMapPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -1163,7 +1173,9 @@ class Elections2021ProgramPage( FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -1754,7 +1766,7 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -1985,7 +1997,9 @@ class Elections2021QuestionsPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -2043,7 +2057,7 @@ class Elections2021ProgramAppPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -2133,7 +2147,7 @@ class Elections2021TextPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -2165,7 +2179,7 @@ class Elections2021StrategicListPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -2237,7 +2251,7 @@ class Elections2021StrategicPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -2276,7 +2290,7 @@ class Elections2021MythsPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -2343,7 +2357,11 @@ class Elections2021MythPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("slug"), FieldPanel("seo_title"), FieldPanel("search_description"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_DESCRIPTION_USE_PEREX)), + HelpPanel( + admin_help.build( + admin_help.NO_SEO_TITLE, admin_help.NO_DESCRIPTION_USE_PEREX + ) + ), ], gettext_lazy("Common page configuration"), ), @@ -2435,7 +2453,7 @@ class Elections2021DownloadsPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -2507,7 +2525,9 @@ class Elections2021GovernmentTeamPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -2555,7 +2575,9 @@ class Elections2021CalendarPage(SubpageMixin, MetadataPageMixin, CalendarMixin, FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -2671,7 +2693,9 @@ class Elections2021BannerListPage( FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -2869,7 +2893,9 @@ class Elections2021MapPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)), + HelpPanel( + admin_help.build(admin_help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO) + ), ], gettext_lazy("Common page configuration"), ), @@ -2949,7 +2975,7 @@ class Elections2021ProgramInNutshellPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -3163,7 +3189,7 @@ class Elections2021GoingToVotePage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE)), + HelpPanel(admin_help.build(admin_help.NO_SEO_TITLE)), ], gettext_lazy("Common page configuration"), ), diff --git a/green_deal/models.py b/green_deal/models.py index 03e9cc96adbf345a229318cab9f032decd99d66b..d4e05d8fdaa5f354c3ec8cdfa9d2157ed6c7109b 100644 --- a/green_deal/models.py +++ b/green_deal/models.py @@ -15,7 +15,7 @@ from wagtail.images.blocks import ImageChooserBlock from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin -from tuning import help +from tuning import admin_help RICH_TEXT_FEATURES = [ "h2", @@ -116,7 +116,7 @@ class GreenDealHomePage(MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), + HelpPanel(admin_help.build(admin_help.IMPORTANT_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -169,7 +169,7 @@ class GreenDealSubPage(Page, MetadataPageMixin): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), + HelpPanel(admin_help.build(admin_help.IMPORTANT_TITLE)), ], gettext_lazy("Common page configuration"), ), diff --git a/region/models.py b/region/models.py index d75865e039084e501a4953a7910a810b9d2166da..02a3d8a721fb745c61ab22a878016d0b852451ef 100644 --- a/region/models.py +++ b/region/models.py @@ -9,7 +9,6 @@ from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey from taggit.models import Tag, TaggedItemBase from wagtail.admin.edit_handlers import ( - CommentPanel, FieldPanel, HelpPanel, MultiFieldPanel, @@ -28,6 +27,8 @@ from wagtailmetadata.models import MetadataPageMixin from calendar_utils.models import CalendarMixin from shared.models import ArticleMixin, MenuMixin, SubpageMixin +from shared.utils import make_promote_panels +from tuning import admin_help from uniweb.constants import RICH_TEXT_FEATURES from . import blocks @@ -182,17 +183,7 @@ class RegionHomePage(MenuMixin, MetadataPageMixin, CalendarMixin, Page): FieldPanel("show_calendar_on_hp"), ] - promote_panels = MetadataPageMixin.promote_panels + [ - MultiFieldPanel( - [ - FieldPanel("facebook"), - FieldPanel("forum"), - FieldPanel("twitter"), - FieldPanel("youtube"), - ], - gettext_lazy("Social page configuration"), - ), - ] + promote_panels = make_promote_panels(admin_help.build(admin_help.IMPORTANT_TITLE)) settings_panels = [ ImageChooserPanel("custom_logo"), @@ -233,14 +224,14 @@ class RegionHomePage(MenuMixin, MetadataPageMixin, CalendarMixin, Page): gettext_lazy("Nastavení lišty s kalendářem a mapou"), ), ImageChooserPanel("fallback_image"), - CommentPanel(), ] ### EDIT HANDLERS + edit_handler = TabbedInterface( [ ObjectList(content_panels, heading="Obsah"), - ObjectList(MetadataPageMixin.promote_panels, heading="Propagovat"), + ObjectList(promote_panels, heading="Propagovat"), ObjectList(settings_panels, heading="Nastavení"), ObjectList(MenuMixin.menu_panels, heading="Menu"), ] @@ -343,6 +334,8 @@ class RegionArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Page): FieldPanel("tags"), ] + promote_panels = make_promote_panels() + ### RELATIONS parent_page_types = ["region.RegionArticlesPage"] @@ -378,7 +371,7 @@ class RegionArticlesPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("max_items"), ] - settings_panels = [CommentPanel()] + promote_panels = make_promote_panels() import_panels = [ MultiFieldPanel( @@ -407,7 +400,7 @@ class RegionArticlesPage(SubpageMixin, MetadataPageMixin, Page): edit_handler = TabbedInterface( [ ObjectList(content_panels, heading="Obsah"), - ObjectList(settings_panels, heading="Nastavení"), + ObjectList(promote_panels, heading="Propagovat"), ObjectList(import_panels, heading="Import"), ] ) @@ -450,6 +443,10 @@ class RegionContactPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("text"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["region.RegionHomePage"] @@ -464,7 +461,9 @@ class RegionContactPage(SubpageMixin, MetadataPageMixin, Page): class RegionTagsPage(SubpageMixin, MetadataPageMixin, Page): ### PANELS - settings_panels = [CommentPanel()] + promote_panels = make_promote_panels() + + settings_panels = [] ### RELATIONS @@ -691,7 +690,9 @@ class RegionPeoplePage(SubpageMixin, MetadataPageMixin, Page): content_panels = Page.content_panels + [StreamFieldPanel("content")] - settings_panels = [CommentPanel()] + promote_panels = make_promote_panels() + + settings_panels = [] ### RELATIONS @@ -706,13 +707,16 @@ class RegionPeoplePage(SubpageMixin, MetadataPageMixin, Page): class RegionElectionBasePage(SubpageMixin, MetadataPageMixin, Page): ### FIELDS + text = RichTextField("text", blank=True, features=RICH_TEXT_FEATURES) ### PANELS - content_panels = Page.content_panels + [ - FieldPanel("text"), - ] + content_panels = Page.content_panels + [FieldPanel("text")] + + promote_panels = make_promote_panels() + + settings_panels = [] ### RELATIONS @@ -781,6 +785,10 @@ class RegionElectionPage(SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["region.RegionHomePage"] @@ -834,6 +842,10 @@ class RegionProgramPage(SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["region.RegionHomePage"] @@ -882,6 +894,10 @@ class RegionCenterPage(CalendarMixin, SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("sidebar_content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["region.RegionHomePage"] @@ -933,6 +949,10 @@ class RegionCrossroadPage(SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["region.RegionHomePage"] @@ -977,6 +997,10 @@ class RegionCustomPage(SubpageMixin, MetadataPageMixin, Page): StreamFieldPanel("content"), ] + promote_panels = make_promote_panels() + + settings_panels = [] + ### RELATIONS parent_page_types = ["region.RegionHomePage", "region.RegionCrossroadPage"] diff --git a/regulace_konopi/models.py b/regulace_konopi/models.py index 7c1f01ec9bca7ccf67c4f69dd4f538b72b71224f..988f9bdb14e967c29d61de55cf52d0759dfe5388 100644 --- a/regulace_konopi/models.py +++ b/regulace_konopi/models.py @@ -14,7 +14,7 @@ from wagtail.images.blocks import ImageChooserBlock from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin -from tuning import help +from tuning import admin_help SUPPORT_CHOICES = ((1, "Pro"), (0, "Proti"), (-1, "Nevíme")) @@ -129,7 +129,7 @@ class RegkonHomePage(MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), + HelpPanel(admin_help.build(admin_help.IMPORTANT_TITLE)), ], gettext_lazy("Common page configuration"), ), @@ -222,7 +222,11 @@ class RegkonSubPage(Page, MetadataPageMixin): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), + HelpPanel( + admin_help.build( + admin_help.NO_SEO_TITLE, admin_help.NO_SEARCH_IMAGE + ) + ), ], gettext_lazy("Common page configuration"), ), diff --git a/senat_campaign/models.py b/senat_campaign/models.py index f670187b86fdb6f6e323724c1ef802c45d9b4ef3..71812244007f65729f0cf72f936e8285f6b70255 100644 --- a/senat_campaign/models.py +++ b/senat_campaign/models.py @@ -19,7 +19,7 @@ from wagtailmetadata.models import MetadataPageMixin from calendar_utils.models import CalendarMixin from shared.models import SubpageMixin -from tuning import help +from tuning import admin_help HELP_COMBINED_TITLE = ( "Pokud není zadán <strong>Titulek stránky</strong>, použije se " @@ -160,8 +160,8 @@ class SenatCampaignHomePage(Page, MetadataPageMixin, CalendarMixin): FieldPanel("search_description"), ImageChooserPanel("search_image"), HelpPanel( - help.build( - help.IMPORTANT_TITLE, + admin_help.build( + admin_help.IMPORTANT_TITLE, "Pokud není zadán <strong>Search image</strong>, použije se úvodní foto kandidáta.", ) ), @@ -292,7 +292,9 @@ class SenatCampaignNewsIndexPage(Page, SubpageMixin, MetaMixin, MetadataPageMixi FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(HELP_COMBINED_TITLE, help.NO_SEARCH_IMAGE)), + HelpPanel( + admin_help.build(HELP_COMBINED_TITLE, admin_help.NO_SEARCH_IMAGE) + ), ], gettext_lazy("Common page configuration"), ), @@ -364,7 +366,7 @@ class SenatCampaignNewsPage(Page, SubpageMixin, MetaMixin, MetadataPageMixin): FieldPanel("seo_title"), FieldPanel("search_description"), HelpPanel( - help.build( + admin_help.build( HELP_COMBINED_TITLE, "Pokud není zadán <strong>Popis vyhledávání</strong>, použije se prvních 150 znaků <strong>Perexu</strong> (tab obsah).", ) @@ -454,7 +456,9 @@ class SenatCampaignProgramPage(Page, SubpageMixin, MetaMixin, MetadataPageMixin) FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(HELP_COMBINED_TITLE, help.NO_SEARCH_IMAGE)), + HelpPanel( + admin_help.build(HELP_COMBINED_TITLE, admin_help.NO_SEARCH_IMAGE) + ), ], gettext_lazy("Common page configuration"), ), @@ -494,7 +498,9 @@ class SenatCampaignCookiesPage(Page, SubpageMixin, MetaMixin, MetadataPageMixin) FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(HELP_COMBINED_TITLE, help.NO_SEARCH_IMAGE)), + HelpPanel( + admin_help.build(HELP_COMBINED_TITLE, admin_help.NO_SEARCH_IMAGE) + ), ], gettext_lazy("Common page configuration"), ), diff --git a/senate/models.py b/senate/models.py index 7aaad81fe4e4f23f5dc75f17bc5d994409990a91..f7ad86f4d29c3b7ab9af6b6500a8302bfb43d922 100644 --- a/senate/models.py +++ b/senate/models.py @@ -14,7 +14,7 @@ from wagtail.images.blocks import ImageChooserBlock from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin -from tuning import help +from tuning import admin_help class PersonBlock(blocks.StructBlock): @@ -61,7 +61,7 @@ class SenateHomePage(MetadataPageMixin, Page): FieldPanel("seo_title"), FieldPanel("search_description"), ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), + HelpPanel(admin_help.build(admin_help.IMPORTANT_TITLE)), ], gettext_lazy("Common page configuration"), ), diff --git a/shared/models.py b/shared/models.py index 847f58547e2ceeffcce05ac380287f4e5bfeb874..a145e5484ff5ffc9c4069a1f6ae1bae1d01f71b5 100644 --- a/shared/models.py +++ b/shared/models.py @@ -1,6 +1,11 @@ from django.db import models from django.utils import timezone -from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel, StreamFieldPanel +from wagtail.admin.edit_handlers import ( + FieldPanel, + MultiFieldPanel, + PublishingPanel, + StreamFieldPanel, +) from wagtail.core.blocks import RichTextBlock from wagtail.core.fields import StreamField from wagtail.core.models import Page @@ -79,6 +84,8 @@ class ArticleMixin(models.Model): ImageChooserPanel("image"), ] + settings_panels = [PublishingPanel()] + class Meta: abstract = True diff --git a/shared/utils.py b/shared/utils.py index 7ecc0e5fee48a4aaae68b13fc5c2e13051a9951d..44972b09c018ca0983ea64172fd9c4894955a354 100644 --- a/shared/utils.py +++ b/shared/utils.py @@ -3,7 +3,17 @@ import logging import requests from django.conf import settings +from django.utils.translation import gettext_lazy +from wagtail.admin.edit_handlers import ( + CommentPanel, + FieldPanel, + HelpPanel, + MultiFieldPanel, +) from wagtail.core.models import Page +from wagtail.images.edit_handlers import ImageChooserPanel + +from tuning import admin_help logger = logging.getLogger() @@ -15,6 +25,27 @@ def get_subpage_url(page, dest_page_type): return "#" +def make_promote_panels( + help_content=None, *, seo_title=True, search_description=True, search_image=True +): + if help_content is None: + help_content = admin_help.build( + admin_help.NO_SEO_TITLE, admin_help.NO_SEARCH_IMAGE + ) + + panels = [FieldPanel("slug")] + if seo_title: + panels.append(FieldPanel("seo_title")) + if search_description: + panels.append(FieldPanel("search_description")) + if search_image: + panels.append(ImageChooserPanel("search_image")) + panels.append(HelpPanel(help_content)) + panels.append(CommentPanel()) + + return [MultiFieldPanel(panels, gettext_lazy("Common page configuration"))] + + def subscribe_to_newsletter(email, news_id, source): payload = { "email": email, diff --git a/tuning/help.py b/tuning/admin_help.py similarity index 100% rename from tuning/help.py rename to tuning/admin_help.py diff --git a/uniweb/models.py b/uniweb/models.py index 37b1bcd46baf6591961d21e11f3c0f4d215dc204..f4dc030c1efe036bf85b8dba8a0860a7cd20ca50 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -9,7 +9,6 @@ from taggit.models import TaggedItemBase from wagtail.admin.edit_handlers import ( CommentPanel, FieldPanel, - HelpPanel, InlinePanel, MultiFieldPanel, ObjectList, @@ -24,12 +23,12 @@ from wagtail.core import blocks from wagtail.core.fields import StreamField from wagtail.core.models import Page from wagtail.images.blocks import ImageChooserBlock -from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin from calendar_utils.models import CalendarMixin from shared.models import ArticleMixin, SubpageMixin -from tuning import help +from shared.utils import make_promote_panels +from tuning import admin_help from .constants import ( ALIGN_CHOICES, @@ -323,21 +322,9 @@ class UniwebHomePage(Page, MetadataPageMixin, CalendarMixin): ### PANELS - content_panels = Page.content_panels + [ - StreamFieldPanel("content"), - ] + content_panels = Page.content_panels + [StreamFieldPanel("content")] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.IMPORTANT_TITLE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels(admin_help.build(admin_help.IMPORTANT_TITLE)) settings_panels = [ MultiFieldPanel( @@ -348,7 +335,6 @@ class UniwebHomePage(Page, MetadataPageMixin, CalendarMixin): "nastavení webu", ), FieldPanel("calendar_url"), - CommentPanel(), MultiFieldPanel( [ FieldPanel("show_logo"), @@ -403,24 +389,13 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin): ### PANELS - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() content_panels = Page.content_panels + [ StreamFieldPanel("content"), ] - settings_panels = [CommentPanel()] + settings_panels = [] ### RELATIONS @@ -442,20 +417,9 @@ class UniwebArticlesIndexPage(Page, SubpageMixin, MetadataPageMixin): ### PANELS - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() - settings_panels = [CommentPanel()] + settings_panels = [] ### RELATIONS @@ -486,7 +450,7 @@ class UniwebArticlesIndexPage(Page, SubpageMixin, MetadataPageMixin): return context -class UniwebArticlePage(Page, ArticleMixin, SubpageMixin, MetadataPageMixin): +class UniwebArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Page): ### FIELDS tags = ClusterTaggableManager(through=UniwebArticleTag, blank=True) @@ -495,20 +459,7 @@ class UniwebArticlePage(Page, ArticleMixin, SubpageMixin, MetadataPageMixin): content_panels = ArticleMixin.content_panels + [FieldPanel("tags")] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] - - settings_panels = [PublishingPanel(), CommentPanel()] + promote_panels = make_promote_panels() ### RELATIONS @@ -561,22 +512,9 @@ class UniwebFormPage(AbstractForm, SubpageMixin, MetadataPageMixin): StreamFieldPanel("content_landing"), ] - promote_panels = [ - MultiFieldPanel( - [ - FieldPanel("slug"), - FieldPanel("seo_title"), - FieldPanel("search_description"), - ImageChooserPanel("search_image"), - HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)), - ], - gettext_lazy("Common page configuration"), - ), - ] + promote_panels = make_promote_panels() - submissions_panels = [ - FormSubmissionsPanel(), - ] + submissions_panels = [FormSubmissionsPanel()] edit_handler = TabbedInterface( [