week titles

This commit is contained in:
j 2023-08-31 18:24:52 +01:00
commit bd6f03491c
5 changed files with 57 additions and 6 deletions

View file

@ -34,7 +34,12 @@ def format_week(week):
fmt = '%b %d'
a = a.strftime(fmt)
b = b.strftime(fmt)
return '%s - %s' % (a, b)
extra = models.Week.objects.filter(monday=week).first()
if extra:
extra = ': ' + extra.title
else:
extra = ''
return '%s - %s%s' % (a, b, extra)
def get_weeks(archive):
@ -80,6 +85,9 @@ def archive(request, year=None, month=None, day=None, week=None):
context['weeks'] = get_weeks(archive)
context['this_week'] = date.strftime('%Y-%m-%d')
context['this_year'] = date.strftime('%Y')
extra = models.Week.objects.filter(monday=context['this_week']).first()
if extra:
context['week_title'] = extra.title
elif week:
week = int(week)
year = int(year)