Skip to content

Commit

Permalink
Created landing page block for homepage midsection. Now need to do te…
Browse files Browse the repository at this point in the history
…mplate
  • Loading branch information
SamuelmdLow committed Sep 17, 2024
1 parent 111f076 commit bcea2ff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 0 additions & 2 deletions article/templatetags/articletags.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def display_pubdate(value):
pubdate = value.astimezone(timezone.get_current_timezone())
today = timezone.now().astimezone(timezone.get_current_timezone())
delta = today - pubdate
print(today.date())
print(pubdate.date())

if delta.total_seconds() > datetime.timedelta(days=365).total_seconds():
return pubdate.strftime("%B xx%d, %Y").replace("xx0","").replace("xx","")
Expand Down
14 changes: 14 additions & 0 deletions home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.db.models import Q

from wagtail import blocks
from wagtail.models import Page
from wagtail.blocks import field_block
from infinitefeed.blocks import AbstractArticleList

Expand Down Expand Up @@ -170,4 +171,17 @@ def get_context(self, value, parent_context=None):
context['title'] = value['category'].title
context['link'] = value['category'].section_page.url + "category/" + value['category'].slug
context['articles'] = ArticlePage.objects.live().public().filter(category=value['category']).order_by('-first_published_at')[:9]
return context

class SpecialLandingPageBlock(AbstractArticleList):
landing = field_block.PageChooserBlock(
page_type='specialfeaturelanding.SpecialLandingPage'
)
template = MidStreamListTemplates()

def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context=parent_context)
context['title'] = value['landing'].title
context['link'] = value['landing'].url
context['articles'] = [value['landing']] + list(Page.objects.child_of(value['landing']).all())
return context
1 change: 1 addition & 0 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class HomePage(Page):
("links", homeblocks.LinksStreamBlock()),
('section', homeblocks.SectionBlock()),
('category', homeblocks.CategoryBlock()),
('landing', homeblocks.SpecialLandingPageBlock()),
('tag', homeblocks.TagBlock()),
],
null=True,
Expand Down
4 changes: 2 additions & 2 deletions section/templates/section/objects/section_timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h2><a href="{{link}}">{{title}}</a></h2>
{% endif %}
<div class="o-article__right">
<div class="o-article__meta">
<p class="o-article__published">{{ article.explicit_published_at|display_pubdate }}</p>
<p class="o-article__published">{% if article.explicit_published_at %}{{ article.explicit_published_at|display_pubdate }}{% else %}{{ article.first_published_at|display_pubdate }}{%endif%}</p>
<h3 class="o-article__headline">
<a href="{% pageurl article %}">{{ article.title|safe }}</a>
</h3>
Expand All @@ -55,7 +55,7 @@ <h3 class="o-article__headline">
<div class="bullet"></div>
{% endif %}
<article class="o-article o-article--bullet">
{% if forloop.counter == 1 %}<p class="o-article__published">{{ article.explicit_published_at|display_pubdate }}</p>{% endif %}
{% if forloop.counter == 1 %}<p class="o-article__published">{% if article.explicit_published_at %}{{ article.explicit_published_at|display_pubdate }}{% else %}{{ article.first_published_at|display_pubdate }}{%endif%}</p>{% endif %}
<h3 class="o-article__headline">
<a href={% pageurl article %}>{{ article.title|safe }}</a>
</h3>
Expand Down

0 comments on commit bcea2ff

Please sign in to comment.