diff --git a/website/blog/__init__.py b/website/blog/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/blog/migrations/0001_initial.py b/website/blog/migrations/0001_initial.py new file mode 100644 index 0000000..1fe389a --- /dev/null +++ b/website/blog/migrations/0001_initial.py @@ -0,0 +1,77 @@ +# Generated by Django 4.0.5 on 2022-06-19 18:13 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ("wagtailimages", "0024_index_image_file_hash"), + ("wagtailcore", "0069_log_entry_jsonfield"), + ] + + operations = [ + migrations.CreateModel( + name="BlogPostPage", + fields=[ + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.page", + ), + ), + ("subtitle", models.CharField(blank=True, max_length=255)), + ( + "hero_image", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="wagtailimages.image", + ), + ), + ], + options={ + "abstract": False, + }, + bases=("wagtailcore.page", models.Model), + ), + migrations.CreateModel( + name="BlogListPage", + fields=[ + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.page", + ), + ), + ("subtitle", models.CharField(blank=True, max_length=255)), + ( + "hero_image", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="wagtailimages.image", + ), + ), + ], + options={ + "abstract": False, + }, + bases=("wagtailcore.page", models.Model), + ), + ] diff --git a/website/blog/migrations/__init__.py b/website/blog/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/blog/models.py b/website/blog/models.py new file mode 100644 index 0000000..3669bc1 --- /dev/null +++ b/website/blog/models.py @@ -0,0 +1,24 @@ +from typing import Any + +from django.http.request import HttpRequest + +from website.common.models import BaseContentMixin, BasePage + + +class BlogListPage(BaseContentMixin, BasePage): # type: ignore[misc] + max_count = 1 + subpage_types = ["blog.BlogPostPage"] + content_panels = BasePage.content_panels + BaseContentMixin.content_panels + + def get_context(self, request: HttpRequest) -> dict: + context = super().get_context(request) + context["child_pages"] = ( + self.get_children().live().specific().select_related("hero_image") + ) + return context + + +class BlogPostPage(BaseContentMixin, BasePage): # type: ignore[misc] + subpage_types: list[Any] = [] + parent_page_types = [BlogListPage] + content_panels = BasePage.content_panels + BaseContentMixin.content_panels diff --git a/website/blog/templates/blog/blog_list_page.html b/website/blog/templates/blog/blog_list_page.html new file mode 100644 index 0000000..7cac715 --- /dev/null +++ b/website/blog/templates/blog/blog_list_page.html @@ -0,0 +1,13 @@ +{% extends "wagtail_base.html" %} + +{% block content %} + +{% include "common/hero.html" %} + +
+ {% for page in child_pages %} + {% include "common/listing-item.html" %} + {% endfor %} +
+ +{% endblock content %} diff --git a/website/blog/templates/blog/blog_post_page.html b/website/blog/templates/blog/blog_post_page.html new file mode 100644 index 0000000..e0ca9c1 --- /dev/null +++ b/website/blog/templates/blog/blog_post_page.html @@ -0,0 +1,11 @@ +{% extends "wagtail_base.html" %} + +{% block content %} + +{% include "common/hero.html" %} + +
+ {% lorem 10 p %} +
+ +{% endblock content %} diff --git a/website/settings.py b/website/settings.py index 0955957..7ae2ac8 100644 --- a/website/settings.py +++ b/website/settings.py @@ -22,6 +22,7 @@ INSTALLED_APPS = [ "website.common", "website.home", "website.search", + "website.blog", "wagtail.contrib.forms", "wagtail.contrib.redirects", "wagtail.embeds",