Skip to content

Commit 95b3324

Browse files
committed
removing article date from blog post, adding category to blog post
1 parent e9603b8 commit 95b3324

File tree

5 files changed

+30
-37
lines changed

5 files changed

+30
-37
lines changed

cdhweb/blog/migrations/0018_bloglandingpage_and_more.py renamed to cdhweb/blog/migrations/0017_bloglandingpage_and_more.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 5.0.5 on 2024-06-11 22:55
1+
# Generated by Django 5.0.5 on 2024-06-12 04:24
22

33
import django.db.models.deletion
44
import wagtail.fields
@@ -7,7 +7,7 @@
77

88
class Migration(migrations.Migration):
99
dependencies = [
10-
("blog", "0017_blogpost_article_date"),
10+
("blog", "0016_blogpost_short_description_blogpost_short_title"),
1111
("cdhpages", "0047_alter_contentpage_body_alter_homepage_body_and_more"),
1212
("wagtailcore", "0089_log_entry_data_json_null_to_object"),
1313
]
@@ -47,4 +47,14 @@ class Migration(migrations.Migration):
4747
old_name="BlogLinkPage",
4848
new_name="BlogLinkPageArchived",
4949
),
50+
migrations.AddField(
51+
model_name="blogpost",
52+
name="category",
53+
field=models.CharField(
54+
blank=True,
55+
help_text="Category tag to display on tile",
56+
max_length=20,
57+
verbose_name="Category",
58+
),
59+
),
5060
]

cdhweb/blog/migrations/0017_blogpost_article_date.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

cdhweb/blog/models.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from datetime import date
2+
13
from django.db import models
24
from django.db.models.fields.related import RelatedField
35
from django.urls import reverse
46
from django.utils.dateformat import format
57
from django.utils.functional import cached_property
68
from django.utils.text import Truncator
7-
from django.utils.timezone import localdate
89
from django.utils.translation import gettext_lazy as _
910
from modelcluster.contrib.taggit import ClusterTaggableManager
1011
from modelcluster.fields import ParentalKey
@@ -72,12 +73,6 @@ class BlogPost(BasePage, ClusterableModel):
7273
help_text="Short introduction to the page, aim for max two clear sentences (max. 200 chars).",
7374
)
7475

75-
article_date = models.DateTimeField(
76-
verbose_name="Published date",
77-
default=localdate,
78-
help_text=("Published date for blog post"),
79-
)
80-
8176
image = models.ForeignKey(
8277
"wagtailimages.image",
8378
null=True,
@@ -119,6 +114,13 @@ class BlogPost(BasePage, ClusterableModel):
119114
)
120115
people = models.ManyToManyField(Person, through="blog.Author", related_name="posts")
121116

117+
category = models.CharField(
118+
verbose_name="Category",
119+
help_text="Category tag to display on tile",
120+
blank=True,
121+
max_length=20,
122+
)
123+
122124
# can only be created underneath special link page
123125
parent_page_types = ["blog.BlogLinkPageArchived", "blog.BlogLandingPage"]
124126
# no allowed subpages
@@ -127,7 +129,6 @@ class BlogPost(BasePage, ClusterableModel):
127129
# admin edit configuration
128130
content_panels = Page.content_panels + [
129131
FieldPanel("description"),
130-
FieldPanel("article_date"),
131132
MultiFieldPanel(
132133
[
133134
FieldPanel("image"),
@@ -141,6 +142,7 @@ class BlogPost(BasePage, ClusterableModel):
141142
[InlinePanel("authors", [AutocompletePanel("person")], label="Author")],
142143
heading="Authors",
143144
),
145+
FieldPanel("category"),
144146
FieldPanel("body"),
145147
FieldPanel("attachments"),
146148
]

templates/cdhpages/blocks/tile.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
{# Internal page deets #}
2323
{% if tile_type == 'internal_page_tile' %}
2424

25-
{% if internal_page.specific.page_type != 'Profile' and internal_page.specific.page_type != 'Event' %}
25+
{% if internal_page.specific.page_type == 'BlogPost' %}
26+
<p>{{ internal_page.specific.category }} </p>
27+
<p>{{ internal_page.specific.first_published_at|date:"j F Y" }}</p>
28+
{{ internal_page.specific.short_description|default:internal_page.specific.description|richtext }}
29+
30+
{% elif internal_page.specific.page_type != 'Profile' and internal_page.specific.page_type != 'Event' %}
2631
{{ internal_page.specific.short_description|default:internal_page.specific.description|richtext }}
2732

2833
{# Extra event-specific deets #}
@@ -55,9 +60,7 @@
5560

5661
{% elif internal_page.specific.page_type == 'Profile' %}
5762
</p>{{ internal_page.specific.person.current_title }}</p>
58-
59-
{% elif internal_page.specific.page_type == 'BlogPost' %}
60-
<p>{{ internal_page.specific.article_date|date:"j F Y" }}</p>
63+
6164
{% endif %}
6265

6366
{% else %}

templates/includes/blog_hero.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<h1>{{ page.title }}</h1>
77

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

1212
{% if page.authors %}

0 commit comments

Comments
 (0)