weeks can be breaks
This commit is contained in:
parent
e44e8b3c35
commit
92460179f5
5 changed files with 57 additions and 12 deletions
|
|
@ -69,13 +69,16 @@ def index(request):
|
|||
else:
|
||||
now = None
|
||||
week, archive = models.Item.public(now)
|
||||
context['items'] = week
|
||||
if archive.exists():
|
||||
if archive and archive.exists():
|
||||
context['archive'] = '/_%s/' % get_monday(get_now() - timedelta(days=7))
|
||||
if now:
|
||||
context['now'] = now
|
||||
context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT)
|
||||
context['next_week'] = (now + timedelta(days=7)).strftime(TS_FORMAT)
|
||||
if isinstance(week, models.Week) and week.is_break:
|
||||
context["break"] = week
|
||||
else:
|
||||
context['items'] = week
|
||||
if now:
|
||||
context['now'] = now
|
||||
context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT)
|
||||
context['next_week'] = (now + timedelta(days=7)).strftime(TS_FORMAT)
|
||||
return render(request, 'index.html', context)
|
||||
|
||||
|
||||
|
|
@ -89,9 +92,7 @@ def archive(request, year=None, month=None, day=None, week=None):
|
|||
archive_week = archive.filter(year=year, week=week).order_by('published')
|
||||
years = {}
|
||||
context['weeks'] = get_weeks(archive)
|
||||
years["2024"] = []
|
||||
for week in get_weeks(archive):
|
||||
print(week)
|
||||
if week["year"] not in years:
|
||||
years[week["year"]] = []
|
||||
years[week["year"]].append(week)
|
||||
|
|
@ -104,7 +105,7 @@ def archive(request, year=None, month=None, day=None, week=None):
|
|||
})
|
||||
context['this_week'] = date.strftime('%Y-%m-%d')
|
||||
context['this_year'] = date.strftime('%Y')
|
||||
extra = models.Week.objects.filter(monday=context['this_week']).first()
|
||||
extra = models.Week.objects.filter(monday=context['this_week'], is_break=False).first()
|
||||
if extra:
|
||||
context['week_title'] = extra.title
|
||||
context['week_byline'] = extra.byline
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue