diff --git a/Makefile b/Makefile index f08c746..961e162 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,10 @@ makemessages: @docker compose -f docker-compose.dev.yml run --rm web python manage.py makemessages -l fr @docker compose -f docker-compose.dev.yml run --rm web python manage.py makemessages -l es +makemigrations: + @docker compose -f docker-compose.dev.yml run --rm web python manage.py makemigrations + @docker compose -f docker-compose.dev.yml run --rm web python manage.py migrate + makecompile: @docker compose -f docker-compose.dev.yml run --rm web python manage.py compilemessages diff --git a/container-entrypoint.sh b/container-entrypoint.sh index e969ab7..013f6f9 100644 --- a/container-entrypoint.sh +++ b/container-entrypoint.sh @@ -6,7 +6,9 @@ # phase facilities of your hosting platform. This is used only so the # Wagtail instance can be started with a simple "docker run" command. -# Apply database migrations +# Migrate database +echo "Create database migrations" +python manage.py makemigrations echo "Apply database migrations" python manage.py migrate diff --git a/home/migrations/0003_homepage_landing_page_cta.py b/home/migrations/0003_homepage_landing_page_cta.py new file mode 100644 index 0000000..3303c2b --- /dev/null +++ b/home/migrations/0003_homepage_landing_page_cta.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-04-05 23:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0002_create_homepage'), + ] + + operations = [ + migrations.AddField( + model_name='homepage', + name='landing_page_cta', + field=models.CharField(max_length=100, null=True), + ), + ] diff --git a/home/migrations/0004_remove_homepage_landing_page_cta_homepage_hero_cta_and_more.py b/home/migrations/0004_remove_homepage_landing_page_cta_homepage_hero_cta_and_more.py new file mode 100644 index 0000000..03212b7 --- /dev/null +++ b/home/migrations/0004_remove_homepage_landing_page_cta_homepage_hero_cta_and_more.py @@ -0,0 +1,40 @@ +# Generated by Django 4.2.7 on 2024-04-06 23:44 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('home', '0003_homepage_landing_page_cta'), + ] + + operations = [ + migrations.RemoveField( + model_name='homepage', + name='landing_page_cta', + ), + migrations.AddField( + model_name='homepage', + name='hero_cta', + field=models.CharField(help_text='Write text for the Call to Action button', max_length=50, null=True), + ), + migrations.AddField( + model_name='homepage', + name='hero_cta_link', + field=models.ForeignKey(blank=True, help_text='Select a page to link to for the Call to Action button', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.page'), + ), + migrations.AddField( + model_name='homepage', + name='hero_text', + field=models.CharField(help_text='Write an introduction for the hero/landing page section', max_length=100, null=True), + ), + migrations.AddField( + model_name='homepage', + name='image', + field=models.ForeignKey(blank=True, help_text='Banner image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + ] diff --git a/home/migrations/0005_alter_homepage_hero_text.py b/home/migrations/0005_alter_homepage_hero_text.py new file mode 100644 index 0000000..711ced9 --- /dev/null +++ b/home/migrations/0005_alter_homepage_hero_text.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-04-08 00:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0004_remove_homepage_landing_page_cta_homepage_hero_cta_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='homepage', + name='hero_text', + field=models.CharField(help_text='Write an introduction for the hero/landing page section', max_length=500, null=True), + ), + ] diff --git a/home/migrations/0006_homepage_carousel.py b/home/migrations/0006_homepage_carousel.py new file mode 100644 index 0000000..9096c31 --- /dev/null +++ b/home/migrations/0006_homepage_carousel.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-04-22 08:24 + +from django.db import migrations +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0005_alter_homepage_hero_text'), + ] + + operations = [ + migrations.AddField( + model_name='homepage', + name='carousel', + field=wagtail.fields.StreamField([('slides', wagtail.blocks.StructBlock([('header', wagtail.blocks.CharBlock(help_text='Slide header', required=True)), ('body', wagtail.blocks.CharBlock(help_text='Slide body', required=True)), ('action_button', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock(help_text='Text to display on the button', required=True)), ('link', wagtail.blocks.URLBlock(help_text='URL to link to', required=True))], help_text='Button to display on the slide', required=False))]))], blank=True, use_json_field=True, verbose_name='Carousel'), + ), + ] diff --git a/home/migrations/0007_alter_homepage_carousel.py b/home/migrations/0007_alter_homepage_carousel.py new file mode 100644 index 0000000..58ee8d9 --- /dev/null +++ b/home/migrations/0007_alter_homepage_carousel.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-04-22 08:43 + +from django.db import migrations +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0006_homepage_carousel'), + ] + + operations = [ + migrations.AlterField( + model_name='homepage', + name='carousel', + field=wagtail.fields.StreamField([('slides', wagtail.blocks.StructBlock([('header', wagtail.blocks.CharBlock(help_text='Slide header', required=True)), ('body', wagtail.blocks.CharBlock(help_text='Slide body', required=True)), ('action_button', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock(help_text='Text to display on the button', required=True)), ('link', wagtail.blocks.URLBlock(blank=True, help_text='URL to link to', required=False))], help_text='Button to display on the slide', required=False))]))], blank=True, use_json_field=True, verbose_name='Carousel'), + ), + ] diff --git a/home/models.py b/home/models.py index 4a42968..18817d1 100644 --- a/home/models.py +++ b/home/models.py @@ -1,6 +1,70 @@ from django.db import models +from wagtail.admin.panels import FieldPanel, MultiFieldPanel +from wagtail.blocks import CharBlock, StreamBlock, StructBlock, URLBlock +from wagtail.fields import StreamField from wagtail.models import Page +class ActionButtonBlock(StructBlock): + text = CharBlock(required=True, help_text="Text to display on the button") + link = URLBlock(required=False, blank=True, help_text="URL to link to") + + +class SlideBlock(StructBlock): + header = CharBlock(required=True, help_text="Slide header") + body = CharBlock(required=True, help_text="Slide body") + action_button = ActionButtonBlock(required=False, help_text="Button to display on the slide") + + +class CarouselBlock(StreamBlock): + slides = SlideBlock() + + class HomePage(Page): - pass + templates = "home/home_page.html" + + # Hero section + image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Banner image", + ) + hero_text = models.CharField( + max_length=500, + blank=False, + null=True, + help_text="Write an introduction for the hero/landing page section", + ) + hero_cta = models.CharField( + max_length=50, blank=False, null=True, help_text="Write text for the Call to Action button" + ) + hero_cta_link = models.ForeignKey( + "wagtailcore.Page", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Select a page to link to for the Call to Action button", + ) + carousel = StreamField( + CarouselBlock(max_num=3, min_num=3), + verbose_name="Carousel", + blank=True, + use_json_field=True, + ) + + content_panels = Page.content_panels + [ + MultiFieldPanel( + [ + FieldPanel("image"), + FieldPanel("hero_text"), + FieldPanel("hero_cta"), + FieldPanel("hero_cta_link"), + ], + heading="Hero Section", + ), + FieldPanel("carousel"), + ] diff --git a/home/templates/home/home_page.html b/home/templates/home/home_page.html index e3059e6..d172c2e 100644 --- a/home/templates/home/home_page.html +++ b/home/templates/home/home_page.html @@ -1,22 +1,88 @@ {% extends "base.html" %} {% load static %} {% load compress %} +{% load wagtailimages_tags %} {% block body_class %} template-homepage {% endblock body_class %} {% block extra_css %} - {% comment %} -Delete the line below if you're just getting started and want to remove the welcome screen! - {% endcomment %} {% compress css %} - {% comment %} {% endcomment %} {% endcompress css %} {% endblock extra_css %} {% block content %} - {% comment %}
Home weeee
-This is the homepage
{% endcomment %} - {% comment %} -Delete the line below if you're just getting started and want to remove the welcome screen! - {% endcomment %} - {% comment %} {% include "home/welcome_page.html" %} {% endcomment %} +