Rename blog post models
A "blog" isn't a blog "post"
This commit is contained in:
parent
adc6002217
commit
3e6547881e
6 changed files with 41 additions and 13 deletions
|
@ -39,7 +39,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-bloglistpage {
|
.page-blogpostlistpage {
|
||||||
.date-header {
|
.date-header {
|
||||||
font-size: $size-2;
|
font-size: $size-2;
|
||||||
font-weight: $weight-bold;
|
font-weight: $weight-bold;
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 4.0.6 on 2022-08-20 12:56
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("unsplash", "0002_unsplashphoto_created_and_more"),
|
||||||
|
("wagtailcore", "0069_log_entry_jsonfield"),
|
||||||
|
("images", "0001_initial"),
|
||||||
|
("blog", "0018_alter_blogcollectionlistpage_body_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name="BlogCollectionListPage",
|
||||||
|
new_name="BlogPostCollectionListPage",
|
||||||
|
),
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name="BlogCollectionPage",
|
||||||
|
new_name="BlogPostCollectionPage",
|
||||||
|
),
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name="BlogListPage",
|
||||||
|
new_name="BlogPostListPage",
|
||||||
|
),
|
||||||
|
]
|
|
@ -15,13 +15,13 @@ from website.common.models import BaseContentPage
|
||||||
from website.common.utils import TocEntry
|
from website.common.utils import TocEntry
|
||||||
|
|
||||||
|
|
||||||
class BlogListPage(RoutablePageMixin, BaseContentPage):
|
class BlogPostListPage(RoutablePageMixin, BaseContentPage):
|
||||||
max_count = 1
|
max_count = 1
|
||||||
subpage_types = [
|
subpage_types = [
|
||||||
"blog.BlogPostPage",
|
"blog.BlogPostPage",
|
||||||
"blog.BlogPostTagListPage",
|
"blog.BlogPostTagListPage",
|
||||||
"blog.BlogCollectionListPage",
|
"blog.BlogPostCollectionListPage",
|
||||||
"blog.BlogCollectionPage",
|
"blog.BlogPostCollectionPage",
|
||||||
]
|
]
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
@ -66,7 +66,7 @@ class BlogListPage(RoutablePageMixin, BaseContentPage):
|
||||||
|
|
||||||
class BlogPostPage(BaseContentPage):
|
class BlogPostPage(BaseContentPage):
|
||||||
subpage_types: list[Any] = []
|
subpage_types: list[Any] = []
|
||||||
parent_page_types = [BlogListPage, "blog.BlogCollectionPage"]
|
parent_page_types = [BlogPostListPage, "blog.BlogPostCollectionPage"]
|
||||||
|
|
||||||
tags = ParentalManyToManyField("blog.BlogPostTagPage", blank=True)
|
tags = ParentalManyToManyField("blog.BlogPostTagPage", blank=True)
|
||||||
date = models.DateField(default=timezone.now)
|
date = models.DateField(default=timezone.now)
|
||||||
|
@ -79,7 +79,7 @@ class BlogPostPage(BaseContentPage):
|
||||||
|
|
||||||
class BlogPostTagListPage(BaseContentPage):
|
class BlogPostTagListPage(BaseContentPage):
|
||||||
max_count = 1
|
max_count = 1
|
||||||
parent_page_types = [BlogListPage]
|
parent_page_types = [BlogPostListPage]
|
||||||
subpage_types = ["blog.BlogPostTagPage"]
|
subpage_types = ["blog.BlogPostTagPage"]
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
@ -106,7 +106,7 @@ class BlogPostTagPage(RoutablePageMixin, BaseContentPage):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_blog_posts(self) -> PageQuerySet:
|
def get_blog_posts(self) -> PageQuerySet:
|
||||||
blog_list_page = BlogListPage.objects.all().live().get()
|
blog_list_page = BlogPostListPage.objects.all().live().get()
|
||||||
return blog_list_page.get_blog_posts().filter(tags=self).order_by("-date")
|
return blog_list_page.get_blog_posts().filter(tags=self).order_by("-date")
|
||||||
|
|
||||||
def get_context(self, request: HttpRequest) -> dict:
|
def get_context(self, request: HttpRequest) -> dict:
|
||||||
|
@ -123,9 +123,9 @@ class BlogPostTagPage(RoutablePageMixin, BaseContentPage):
|
||||||
)(request)
|
)(request)
|
||||||
|
|
||||||
|
|
||||||
class BlogCollectionListPage(BaseContentPage):
|
class BlogPostCollectionListPage(BaseContentPage):
|
||||||
subpage_types: list[Any] = []
|
subpage_types: list[Any] = []
|
||||||
parent_page_types = [BlogListPage]
|
parent_page_types = [BlogPostListPage]
|
||||||
max_count = 1
|
max_count = 1
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
@ -135,8 +135,8 @@ class BlogCollectionListPage(BaseContentPage):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_collections(self) -> PageQuerySet:
|
def get_collections(self) -> PageQuerySet:
|
||||||
blog_list_page = BlogListPage.objects.all().live().get()
|
blog_list_page = BlogPostListPage.objects.all().live().get()
|
||||||
return BlogCollectionPage.objects.child_of(blog_list_page).live()
|
return BlogPostCollectionPage.objects.child_of(blog_list_page).live()
|
||||||
|
|
||||||
def get_context(self, request: HttpRequest) -> dict:
|
def get_context(self, request: HttpRequest) -> dict:
|
||||||
context = super().get_context(request)
|
context = super().get_context(request)
|
||||||
|
@ -144,8 +144,8 @@ class BlogCollectionListPage(BaseContentPage):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class BlogCollectionPage(BaseContentPage):
|
class BlogPostCollectionPage(BaseContentPage):
|
||||||
parent_page_types = [BlogListPage]
|
parent_page_types = [BlogPostListPage]
|
||||||
subpage_types = [BlogPostPage]
|
subpage_types = [BlogPostPage]
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
|
Loading…
Reference in a new issue