diff --git a/district/migrations/0259_districtnewprogrampage_header_image.py b/district/migrations/0259_districtnewprogrampage_header_image.py new file mode 100644 index 0000000000000000000000000000000000000000..f91ece6baa18add1fb9633d1a26d5b096495c0e7 --- /dev/null +++ b/district/migrations/0259_districtnewprogrampage_header_image.py @@ -0,0 +1,20 @@ +# Generated by Django 5.0.6 on 2024-07-23 12:26 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('district', '0258_alter_districtnewprogrampage_program'), + ('wagtailimages', '0026_delete_uploadedimage'), + ] + + operations = [ + migrations.AddField( + model_name='districtnewprogrampage', + name='header_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailimages.image', verbose_name='Obrázek na pozadí hlavičky'), + ), + ] diff --git a/district/models.py b/district/models.py index e3e8f2c6f2e3f0634513a3d738d4ec47f365ab31..4ee9414e8280393102c5ddd5477f05fb13cb53d1 100644 --- a/district/models.py +++ b/district/models.py @@ -579,11 +579,34 @@ class DistrictNewProgramPage(MainProgramPageMixin): use_json_field=True, ) + header_image = models.ForeignKey( + "wagtailimages.Image", + on_delete=models.PROTECT, + blank=True, + null=True, + verbose_name="Obrázek na pozadí hlavičky", + related_name="+", + ) + ### RELATIONS parent_page_types = ["district.DistrictHomePage"] subpage_types = ["district.DistrictCustomPage"] + ### PANELS + + settings_panels = [ + FieldPanel("header_image") + ] + + edit_handler = TabbedInterface( + [ + ObjectList(MainProgramPageMixin.content_panels, heading="Obsah"), + ObjectList(settings_panels, heading="Nastavení"), + ObjectList(MainProgramPageMixin.promote_panels, heading="Metadata"), + ] + ) + class DistrictCrossroadPage( ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin, PageInMenuMixin, Page diff --git a/shared/models/main.py b/shared/models/main.py index 10a792bace75347437828367ace059e003c9c2fa..0f2cd59455ec6d0ba61cfdcaa198d56822ce873f 100644 --- a/shared/models/main.py +++ b/shared/models/main.py @@ -2040,6 +2040,13 @@ class MainProgramPageMixin( settings_panels = [] + edit_handler = TabbedInterface( + [ + ObjectList(content_panels, heading="Obsah"), + ObjectList(promote_panels, heading="Metadata"), + ] + ) + ### RELATIONS # NOTE: Needs to be overridden diff --git a/shared/templates/styleguide2/includes/organisms/header/simple_header.html b/shared/templates/styleguide2/includes/organisms/header/simple_header.html index cb728a4e45683d6b29ddd0098c61a917c8db1066..ce420155c80c3169ddb4aa1147984f1bd2f24691 100644 --- a/shared/templates/styleguide2/includes/organisms/header/simple_header.html +++ b/shared/templates/styleguide2/includes/organisms/header/simple_header.html @@ -1,3 +1,5 @@ +{% load wagtailimages_tags %} + {% if show_scroll_progress %} <div class="__js-root"> <ui-scroll-indicator></ui-scroll-indicator> @@ -33,6 +35,10 @@ " {% if background_image %} + {% if not background_image.url %} + {% image background_image fill-1920x1080 as background_image %} + {% endif %} + style="background-image:url('{{ background_image.url }}')" {% endif %} > diff --git a/shared/templates/styleguide2/program_page.html b/shared/templates/styleguide2/program_page.html index f4ebac4bde0e336aa701e1b223b4024589644b46..51363075781843ea2444eb172e46f2198fe03add 100644 --- a/shared/templates/styleguide2/program_page.html +++ b/shared/templates/styleguide2/program_page.html @@ -13,7 +13,7 @@ :sync-location="true" v-slot="{ isCurrentView, toggleView }" > - {% include 'styleguide2/includes/organisms/header/simple_header_with_ui_switch.html' with title=page.title ui_switch_iterable=page.program %} + {% include 'styleguide2/includes/organisms/header/simple_header_with_ui_switch.html' with title=page.title ui_switch_iterable=page.program background_image=page.header_image %} <main role="main"> {% for program in page.program %}