Try to sort articles, based on their published_dates
This commit is contained in:
parent
74a5faae48
commit
04736aa405
|
@ -72,11 +72,27 @@ class Article:
|
|||
class PublishedUnpublished:
|
||||
@property
|
||||
def published_articles(self):
|
||||
return [x for x in self.articles if x.published_date]
|
||||
results = [x for x in self.articles if x.published_date]
|
||||
|
||||
sorted(
|
||||
results,
|
||||
key=lambda x: x.pubished_date,
|
||||
reverse=True,
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
@property
|
||||
def articles_without_date(self):
|
||||
return [x for x in self.articles if not x.published_date]
|
||||
results = [x for x in self.articles if not x.published_date]
|
||||
|
||||
sorted(
|
||||
results,
|
||||
key=lambda x: x.pubished_date,
|
||||
reverse=True,
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
class Section(PublishedUnpublished):
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
</ul>
|
||||
|
||||
<ul>
|
||||
{% for year, list in site.published_articles|groupby('published_date.year') %}
|
||||
{% for year, list in site.published_articles|reverse|groupby('published_date.year') %}
|
||||
<li><b>{{ year }}</b>
|
||||
<ul>
|
||||
{% for event in list %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<h1>{{ section.parent.key }} >> {{ section.key }}</h1>
|
||||
|
||||
<ul>
|
||||
{% for year, list in section.published_articles|groupby('published_date.year') %}
|
||||
{% for year, list in section.published_articles|reverse|groupby('published_date.year') %}
|
||||
<li><b>{{ year }}</b>
|
||||
<ul>
|
||||
{% for event in list %}
|
||||
|
|
Loading…
Reference in New Issue