Add link to current summary on home feed

This commit is contained in:
Joachim
2021-12-21 11:43:39 +01:00
parent a8e8785106
commit ce6ca49620
4 changed files with 52 additions and 7 deletions

View File

@ -11,6 +11,21 @@ from bookwyrm import models
# December day of first availability
FIRST_DAY = 15
# January day of last availability, 0 for no availability in Jan.
LAST_DAY = 15
def get_annual_summary_year():
"""return the latest available annual summary year or None"""
today = date.today()
if today >= date(today.year, 12, FIRST_DAY) and today <= date(today.year, 12, 31):
return today.year
if LAST_DAY > 0 and today >= date(today.year, 1, 1) and today <= date(today.year, 1, LAST_DAY):
return today.year - 1
return None
def is_year_available(year):