diff --git a/app/item/views.py b/app/item/views.py index 77ccbc2..fb85cdb 100644 --- a/app/item/views.py +++ b/app/item/views.py @@ -83,7 +83,21 @@ def archive(request, year=None, month=None, day=None, week=None): week = int(date.strftime('%W')) year = int(year) 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) + + context['years'] = [] + for year in reversed(sorted(years)): + context['years'].append({ + 'year': year, + 'weeks': years[year] + }) context['this_week'] = date.strftime('%Y-%m-%d') context['this_year'] = date.strftime('%Y') extra = models.Week.objects.filter(monday=context['this_week']).first() diff --git a/app/templates/archive.html b/app/templates/archive.html index cfca179..cdb07bc 100644 --- a/app/templates/archive.html +++ b/app/templates/archive.html @@ -18,20 +18,20 @@ {% if weeks %}
-
- {% for week in weeks %} - {% ifchanged week.year %} + {% for year in years %} +
+

{{ year.year }}

+
+ {% for week in year.weeks %} + {% if week.date == this_week %} + {{ week.title }}
+ {% else %} + {{ week.title }}
+ {% endif %} + {% endfor %}
-

{{ week.year }}

- {% endfor %} -