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 %} +
+ {% if page.image %} + {% image page.image fill-2830x2130 class="absolute inset-0 -z-10 h-full w-full object-cover" %} + {% endif %} + +
+ +
+ +
+
{{ page.hero_text }}
+
+ {% include "components/branded_elements/button.html" with link="" text=page.hero_cta %} +
+
+ +
+ {% for block in page.carousel %} +
+
{{ block.value.header }}
+
{{ block.value.body }}
+ +
+ {{ block.value.action_button.text }} + + + +
+
+
+ {% endfor %} +
+ + + +
+
+
+ +
+
+
468K
+
Total Mappers ⓘ
+
+
+
246.7M
+
Total Map Edits ⓘ
+
+
+
147.5M
+
Buildings Mapped ⓘ
+
+
+
2.7M
+
Roads Mapped(KM) ⓘ
+
+
+
+
{% endblock content %} diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index 8bc8c1f..44e6e5c 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -36,6 +36,7 @@ "utils", "wagtail.contrib.forms", "wagtail.contrib.redirects", + "wagtail.contrib.settings", "wagtail.embeds", "wagtail.sites", "wagtail.users", @@ -86,6 +87,7 @@ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "wagtail.contrib.settings.context_processors.settings", ], }, }, @@ -194,6 +196,7 @@ # Wagtail settings WAGTAIL_SITE_NAME = "hot_osm" +WAGTAILIMAGES_MAX_UPLOAD_SIZE = 20 * 1024 * 1024 # 20MB # Search # https://docs.wagtail.org/en/stable/topics/search/backends.html diff --git a/hot_osm/templates/base.html b/hot_osm/templates/base.html index fbcda82..76da941 100644 --- a/hot_osm/templates/base.html +++ b/hot_osm/templates/base.html @@ -36,10 +36,15 @@ src="https://cdn.jsdelivr.net/npm/alpinejs@3.13.3/dist/cdn.min.js"> - {% include "components/header/header.html" %} - {% block content %} - {% endblock content %} - {% django_browser_reload_script %} - {% wagtailuserbar %} +
+ {% include "components/nav/secondary_desktop_nav.html" %} +
+ {% include "components/header/header.html" %} + {% block content %} + {% endblock content %} +
+ {% django_browser_reload_script %} + {% wagtailuserbar %} +
diff --git a/hot_osm/templates/components/branded_elements/button.html b/hot_osm/templates/components/branded_elements/button.html index 226bb07..3200c92 100644 --- a/hot_osm/templates/components/branded_elements/button.html +++ b/hot_osm/templates/components/branded_elements/button.html @@ -1,5 +1,5 @@ diff --git a/hot_osm/templates/components/branded_elements/link.html b/hot_osm/templates/components/branded_elements/link.html index 70127c6..19b80cb 100644 --- a/hot_osm/templates/components/branded_elements/link.html +++ b/hot_osm/templates/components/branded_elements/link.html @@ -1,16 +1,15 @@ {{ text }} {% if parent|default:False %} - + width="12.816" + height="8.406" + viewBox="0 0 12.816 8.406" + class="ml-2.5"> + {% endif %} diff --git a/hot_osm/templates/components/branded_elements/social_icons.html b/hot_osm/templates/components/branded_elements/social_icons.html index 4dbb340..2c1cb5f 100644 --- a/hot_osm/templates/components/branded_elements/social_icons.html +++ b/hot_osm/templates/components/branded_elements/social_icons.html @@ -1,7 +1,7 @@ -