Skip to content

Commit

Permalink
removing article date from blog post, adding category to blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahframe committed Jun 12, 2024
1 parent e9603b8 commit 95b3324
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.0.5 on 2024-06-11 22:55
# Generated by Django 5.0.5 on 2024-06-12 04:24

import django.db.models.deletion
import wagtail.fields
Expand All @@ -7,7 +7,7 @@

class Migration(migrations.Migration):
dependencies = [
("blog", "0017_blogpost_article_date"),
("blog", "0016_blogpost_short_description_blogpost_short_title"),
("cdhpages", "0047_alter_contentpage_body_alter_homepage_body_and_more"),
("wagtailcore", "0089_log_entry_data_json_null_to_object"),
]
Expand Down Expand Up @@ -47,4 +47,14 @@ class Migration(migrations.Migration):
old_name="BlogLinkPage",
new_name="BlogLinkPageArchived",
),
migrations.AddField(
model_name="blogpost",
name="category",
field=models.CharField(
blank=True,
help_text="Category tag to display on tile",
max_length=20,
verbose_name="Category",
),
),
]
22 changes: 0 additions & 22 deletions cdhweb/blog/migrations/0017_blogpost_article_date.py

This file was deleted.

18 changes: 10 additions & 8 deletions cdhweb/blog/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from datetime import date

from django.db import models
from django.db.models.fields.related import RelatedField
from django.urls import reverse
from django.utils.dateformat import format
from django.utils.functional import cached_property
from django.utils.text import Truncator
from django.utils.timezone import localdate
from django.utils.translation import gettext_lazy as _
from modelcluster.contrib.taggit import ClusterTaggableManager
from modelcluster.fields import ParentalKey
Expand Down Expand Up @@ -72,12 +73,6 @@ class BlogPost(BasePage, ClusterableModel):
help_text="Short introduction to the page, aim for max two clear sentences (max. 200 chars).",
)

article_date = models.DateTimeField(
verbose_name="Published date",
default=localdate,
help_text=("Published date for blog post"),
)

image = models.ForeignKey(
"wagtailimages.image",
null=True,
Expand Down Expand Up @@ -119,6 +114,13 @@ class BlogPost(BasePage, ClusterableModel):
)
people = models.ManyToManyField(Person, through="blog.Author", related_name="posts")

category = models.CharField(
verbose_name="Category",
help_text="Category tag to display on tile",
blank=True,
max_length=20,
)

# can only be created underneath special link page
parent_page_types = ["blog.BlogLinkPageArchived", "blog.BlogLandingPage"]
# no allowed subpages
Expand All @@ -127,7 +129,6 @@ class BlogPost(BasePage, ClusterableModel):
# admin edit configuration
content_panels = Page.content_panels + [
FieldPanel("description"),
FieldPanel("article_date"),
MultiFieldPanel(
[
FieldPanel("image"),
Expand All @@ -141,6 +142,7 @@ class BlogPost(BasePage, ClusterableModel):
[InlinePanel("authors", [AutocompletePanel("person")], label="Author")],
heading="Authors",
),
FieldPanel("category"),
FieldPanel("body"),
FieldPanel("attachments"),
]
Expand Down
11 changes: 7 additions & 4 deletions templates/cdhpages/blocks/tile.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
{# Internal page deets #}
{% if tile_type == 'internal_page_tile' %}

{% if internal_page.specific.page_type != 'Profile' and internal_page.specific.page_type != 'Event' %}
{% if internal_page.specific.page_type == 'BlogPost' %}
<p>{{ internal_page.specific.category }} </p>
<p>{{ internal_page.specific.first_published_at|date:"j F Y" }}</p>
{{ internal_page.specific.short_description|default:internal_page.specific.description|richtext }}

{% elif internal_page.specific.page_type != 'Profile' and internal_page.specific.page_type != 'Event' %}
{{ internal_page.specific.short_description|default:internal_page.specific.description|richtext }}

{# Extra event-specific deets #}
Expand Down Expand Up @@ -55,9 +60,7 @@

{% elif internal_page.specific.page_type == 'Profile' %}
</p>{{ internal_page.specific.person.current_title }}</p>

{% elif internal_page.specific.page_type == 'BlogPost' %}
<p>{{ internal_page.specific.article_date|date:"j F Y" }}</p>

{% endif %}

{% else %}
Expand Down
2 changes: 1 addition & 1 deletion templates/includes/blog_hero.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h1>{{ page.title }}</h1>

<p class="blog-hero__date">
{{ page.article_date|date:"j F Y" }}
{{ page.first_published_at|date:"j F Y" }}
</p>

{% if page.authors %}
Expand Down

0 comments on commit 95b3324

Please sign in to comment.