Skip to content

Commit

Permalink
Add authors list and category colophon at the end of pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-Crow committed Mar 25, 2024
1 parent b56a77b commit 10cc2c8
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 45 deletions.
70 changes: 47 additions & 23 deletions blog/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-11 16:15+0100\n"
"PO-Revision-Date: 2024-02-27 11:32+0100\n"
"POT-Creation-Date: 2024-03-25 17:57+0100\n"
"PO-Revision-Date: 2024-03-25 17:58+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
Expand All @@ -18,83 +18,107 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.4\n"

#: blog/models.py:34
#: blog/models.py:35
msgid "Posts per page"
msgstr "Articles par page"

#: blog/models.py:44
#: blog/models.py:45
msgid "Blog index"
msgstr "Index de blog"

#: blog/models.py:72 blog/templates/blog/tags_list_page.html:20
#: blog/models.py:73 blog/templates/blog/tags_list_page.html:20
#: blog/views.py:149
msgid "Tags"
msgstr "Étiquettes"

#: blog/models.py:95 blog/models.py:167 blog/models.py:248
#: blog/models.py:96 blog/models.py:169 blog/models.py:264
#: blog/templates/blog/categories_list_page.html:20 blog/views.py:117
msgid "Categories"
msgstr "Catégories"

#: blog/models.py:107 blog/templates/blog/blog_index_page.html:58
#: blog/models.py:108 blog/templates/blog/blog_index_page.html:59
msgid "Posts written by"
msgstr "Articles écrits par"

#: blog/models.py:169
#: blog/models.py:171
msgid "Post date"
msgstr "Date de publication"

#: blog/models.py:175
msgid "Author"
msgstr "Auteur"

#: blog/models.py:187
#: blog/models.py:190
msgid "Scheduled publishing"
msgstr "Publication planifiée"

#: blog/models.py:195
#: blog/models.py:198
msgid "Tags and Categories"
msgstr "Étiquettes et Catégories"

#: blog/models.py:203
#: blog/models.py:206
msgid "Blog page"
msgstr "Page de blog"

#: blog/models.py:208
#: blog/models.py:211
msgid "Category name"
msgstr "Nom de la catégorie"

#: blog/models.py:215
#: blog/models.py:218
msgid "Parent category"
msgstr "Catégorie parente"

#: blog/models.py:218
#: blog/models.py:224
msgid "Description"
msgstr "Description"

#: blog/models.py:229
#: blog/models.py:225
msgid "Displayed on the top of the category page"
msgstr "Affiché en haut de la page de la catégorie"

#: blog/models.py:230
msgid "Colophon"
msgstr "Colophon"

#: blog/models.py:231
msgid "Text displayed at the end of every page in the category"
msgstr "Texte affiché à la fin de chaque page de la catégorie"

#: blog/models.py:244
msgid "Parent category cannot be self."
msgstr "La catégorie ne peut être sa propre parente."

#: blog/models.py:231
#: blog/models.py:246
msgid "Cannot have circular Parents."
msgstr "Il est impossible d’avoir des parents circulaires."

#: blog/models.py:247 blog/models.py:259
#: blog/models.py:263 blog/models.py:275
msgid "Category"
msgstr "Catégorie"

#: blog/models.py:289
msgid "Name"
msgstr "Nom"

#: blog/models.py:290
msgid "Role"
msgstr "Fonction"

#: blog/models.py:305
msgid "Author"
msgstr "Auteur"

#: blog/templates/blog/blog_entry_page.html:78
msgid "Posted by:"
msgstr "Écrit par :"

#: blog/templates/blog/blog_index_page.html:52
#, python-format
msgid "Posts in category %(category)s"
msgstr "Articles dans la catégorie %(category)s"

#: blog/templates/blog/blog_index_page.html:55
#: blog/templates/blog/blog_index_page.html:56
#, python-format
msgid "Posts tagged with %(tag)s"
msgstr "Articles avec l’étiquette %(tag)s"

#: blog/templates/blog/blog_index_page.html:60
#: blog/templates/blog/blog_index_page.html:61
#, python-format
msgid "Posts published in %(year)s"
msgstr "Articles publiés en %(year)s"
Expand Down
41 changes: 41 additions & 0 deletions blog/migrations/0006_author_blogentrypage_authors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 5.0.3 on 2024-03-21 13:54

import django.db.models.deletion
import modelcluster.fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("blog", "0005_delete_tag_blogentrypage_header_cta_text_and_more"),
("wagtailimages", "0025_alter_image_file_alter_rendition_file"),
]

operations = [
migrations.CreateModel(
name="Author",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("name", models.CharField(max_length=255, verbose_name="Name")),
("role", models.CharField(max_length=255, verbose_name="Function")),
(
"author_image",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
),
),
],
options={
"verbose_name": "Author",
},
),
migrations.AddField(
model_name="blogentrypage",
name="authors",
field=modelcluster.fields.ParentalManyToManyField(blank=True, to="blog.author"),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.0.3 on 2024-03-25 16:48

import wagtail.fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("blog", "0006_author_blogentrypage_authors"),
]

operations = [
migrations.AddField(
model_name="category",
name="colophon",
field=wagtail.fields.RichTextField(
blank=True,
help_text="Text displayed at the end of every page in the category",
max_length=500,
verbose_name="Colophon",
),
),
migrations.AlterField(
model_name="author",
name="role",
field=models.CharField(max_length=255, verbose_name="Role"),
),
migrations.AlterField(
model_name="category",
name="description",
field=models.CharField(
blank=True,
help_text="Displayed on the top of the category page",
max_length=500,
verbose_name="Description",
),
),
]
41 changes: 39 additions & 2 deletions blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from taggit.models import TaggedItemBase
from wagtail.admin.panels import FieldPanel, FieldRowPanel, MultiFieldPanel, TitleFieldPanel
from wagtail.admin.widgets.slug import SlugInput
from wagtail.fields import RichTextField
from wagtail.models.i18n import Locale, TranslatableMixin
from wagtail.search import index
from wagtail.snippets.models import register_snippet
Expand Down Expand Up @@ -126,6 +127,7 @@ def get_context(self, request, tag=None, category=None, author=None, year=None,
context["posts"] = posts
if category is not None:
context["category"] = category.name
context["category_description"] = category.description
context["tag"] = tag
context["author"] = author
context["year"] = year
Expand Down Expand Up @@ -167,12 +169,13 @@ class BlogEntryPage(SitesFacilesBasePage):
verbose_name=_("Categories"),
)
date = models.DateTimeField(verbose_name=_("Post date"), default=timezone.now)
authors = ParentalManyToManyField("blog.Author", blank=True)

parent_page_types = ["blog.BlogIndexPage"]
subpage_types = []

settings_panels = SitesFacilesBasePage.settings_panels + [
FieldPanel("owner", heading=_("Author")),
FieldPanel("authors"),
FieldPanel("date"),
MultiFieldPanel(
[
Expand Down Expand Up @@ -215,7 +218,19 @@ class Category(TranslatableMixin, index.Indexed, models.Model):
verbose_name=_("Parent category"),
on_delete=models.SET_NULL,
)
description = models.CharField(max_length=500, blank=True, verbose_name=_("Description"))
description = models.CharField(
max_length=500,
blank=True,
verbose_name=_("Description"),
help_text=_("Displayed on the top of the category page"),
)
colophon = RichTextField(
max_length=500,
blank=True,
verbose_name=_("Colophon"),
help_text=_("Text displayed at the end of every page in the category"),
features=["h2", "h3", "bold", "italic", "link"],
)

objects = CategoryManager()

Expand All @@ -239,6 +254,7 @@ def save(self, *args, **kwargs):
TitleFieldPanel("name"),
FieldPanel("slug", widget=SlugInput),
FieldPanel("description"),
FieldPanel("colophon"),
FieldPanel("parent"),
]

Expand Down Expand Up @@ -266,3 +282,24 @@ def __str__(self):

class TagEntryPage(TaggedItemBase):
content_object = ParentalKey("BlogEntryPage", related_name="entry_tags")


@register_snippet
class Author(models.Model):
name = models.CharField(_("Name"), max_length=255)
role = models.CharField(_("Role"), max_length=255)
author_image = models.ForeignKey(
"wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+"
)

panels = [
FieldPanel("name"),
FieldPanel("role"),
FieldPanel("author_image"),
]

def __str__(self):
return self.name

class Meta:
verbose_name = _("Author")
Loading

0 comments on commit 10cc2c8

Please sign in to comment.