From cbae38e8935352d61612d84012858aabb0cb7cbc Mon Sep 17 00:00:00 2001 From: bkfox Date: Fri, 18 Feb 2022 16:36:05 +0100 Subject: [PATCH] card title block on page_item widget --- aircox/models/episode.py | 7 ++ .../aircox/widgets/basepage_item.html | 65 +++++++++++++++++++ .../aircox/widgets/episode_item.html | 6 +- .../templates/aircox/widgets/page_item.html | 64 ++---------------- 4 files changed, 81 insertions(+), 61 deletions(-) create mode 100644 aircox/templates/aircox/widgets/basepage_item.html diff --git a/aircox/models/episode.py b/aircox/models/episode.py index 6cb5928..493fceb 100644 --- a/aircox/models/episode.py +++ b/aircox/models/episode.py @@ -62,6 +62,13 @@ class Episode(Page): raise ValueError('missing parent program') super().save(*args, **kwargs) + @classmethod + def get_default_title(cls, page, date): + return settings.AIRCOX_EPISODE_TITLE.format( + program=page, + date=date.strftime(settings.AIRCOX_EPISODE_TITLE_DATE_FORMAT) + ) + @classmethod def get_init_kwargs_from(cls, page, date, title=None, **kwargs): """ Get default Episode's title """ diff --git a/aircox/templates/aircox/widgets/basepage_item.html b/aircox/templates/aircox/widgets/basepage_item.html new file mode 100644 index 0000000..61dc067 --- /dev/null +++ b/aircox/templates/aircox/widgets/basepage_item.html @@ -0,0 +1,65 @@ +{% load i18n easy_thumbnails_tags aircox %} +{% comment %} +List item for a page + +Context variables: +- object: the object to render +- render_card: render as card +- is-primary: render as primary +- has_headline (=False): if True, display headline +- has_cover (=True): hide page cover +{% endcomment %} + +{% if render_card %} +
+
+
+ +
+
+ +
+ + +{% else %} +
+ {% if has_cover|default_if_none:True %} +
+ +
+ {% endif %} +
+
+ {% block title %} + {% if object.is_published %} + {{ object.title }} + {% else %} + {{ object.title }} + {% endif %} + {% endblock %} +
+
+ {% block subtitle %} + {% if object.category %}{{ object.category.title }}{% endif %} + {% endblock %} +
+ + {% if has_headline|default_if_none:True %} +
+ {% block headline %}{{ object.headline }}{% endblock %} +
+ {% endif %} +
+ + {% block actions %}{% endblock %} +
+{% endif %} + + diff --git a/aircox/templates/aircox/widgets/episode_item.html b/aircox/templates/aircox/widgets/episode_item.html index e89da25..acd8f68 100644 --- a/aircox/templates/aircox/widgets/episode_item.html +++ b/aircox/templates/aircox/widgets/episode_item.html @@ -13,7 +13,11 @@ Context variables: {% block title %} {% if not object.is_published and object.program.is_published %} - {{ object.title }} + {{ object.program.title }} + {% if diffusion %} + — + {{ diffusion.start|date:"d F" }} + {% endif %} {% else %} {{ block.super }} diff --git a/aircox/templates/aircox/widgets/page_item.html b/aircox/templates/aircox/widgets/page_item.html index 6c15d79..954f232 100644 --- a/aircox/templates/aircox/widgets/page_item.html +++ b/aircox/templates/aircox/widgets/page_item.html @@ -1,62 +1,6 @@ -{% load i18n easy_thumbnails_tags aircox %} -{% comment %} -List item for a page +{% extends "aircox/widgets/basepage_item.html" %} -Context variables: -- object: the object to render -- render_card: render as card -- is-primary: render as primary -- has_headline (=False): if True, display headline -- has_cover (=True): hide page cover -{% endcomment %} - -{% if render_card %} -
-
-
- -
-
- -
- - -{% else %} -
- {% if has_cover|default_if_none:True %} -
- -
- {% endif %} -
-
- {% block title %} - {% if object.is_published %} - {{ object.title }} - {% else %} - {{ object.title }} - {% endif %} - {% endblock %} -
-
- {% block subtitle %} - {% if object.category %}{{ object.category.title }}{% endif %} - {% endblock %} -
- - {% if has_headline|default_if_none:True %} -
- {% block headline %}{{ object.headline }}{% endblock %} -
- {% endif %} -
- - {% block actions %}{% endblock %} -
-{% endif %} +{% block card_title %} +{% block title %}{{ block.super }}{% endblock %} +{% endblock %}