Skip to content
Snippets Groups Projects
Select Git revision
  • aac6d1d3cb6ab603ac90ef62253fe11ace92db8a
  • master default protected
  • feat/new-image-formats
  • clickable-select-chevron
  • 2.20.0
  • 2.19.0
  • 2.18.0
  • 2.17.0
  • 2.16.1
  • 2.16.0
  • 2.15.0
  • 2.14.0
  • 2.13.0
  • 2.12.1
  • 2.11.0
  • 2.10.0
  • 2.9.1
  • 2.9.0
  • 2.8.0
  • 2.7.1
  • 2.7.0
  • 2.6.0
  • 2.5.2
  • 2.5.1
24 results

01-text-input.mustache

Blame
  • wagtail_hooks.py 1.45 KiB
    import re
    
    from django.conf import settings
    from django.contrib.postgres.lookups import Unaccent
    from django.db.models.functions import Lower
    from django.utils.safestring import mark_safe
    from wagtail import hooks
    from wagtail.admin.ui.components import Component
    
    
    class WelcomePanel(Component):
        order = 1000
    
        def render_html(self, parent_context):
            return mark_safe(
                """
            <section class="nice-padding">
              <div class="help-block help-info">
                <p>Nevíte si rady? Nápovědu naleznete na <a href="https://majak.pirati.cz/">majak.pirati.cz</a></p>
              </div>
            </section>
            """
            )
    
    
    @hooks.register("construct_homepage_panels")
    def add_another_welcome_panel(request, panels):
        panels.append(WelcomePanel())
    
    
    @hooks.register("construct_explorer_page_queryset")
    def show_my_profile_only(parent_page, pages, request):
        requested_html = re.search(r"^text/html", request.META.get("HTTP_ACCEPT"))
        if not requested_html:
            return pages.order_by(Unaccent(Lower("title")))
        return pages
    
    
    @hooks.register("insert_global_admin_css")
    def global_admin_css():
        if settings.MAJAK_ENV == "test":
            return mark_safe(
                '<style type="text/css">.sidebar__inner { background-color: #00203A }</style>'
            )
        if settings.MAJAK_ENV == "dev":
            return mark_safe(
                '<style type="text/css">.sidebar__inner { background-color: #002A20 }</style>'
            )
        return ""