current year first, sort latest to oldes withing year
This commit is contained in:
parent
2d91dfcacb
commit
641097e2d3
2 changed files with 26 additions and 12 deletions
|
@ -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()
|
||||
|
|
|
@ -18,20 +18,20 @@
|
|||
</div>
|
||||
{% if weeks %}
|
||||
<div class="weeks">
|
||||
<div>
|
||||
{% for week in weeks %}
|
||||
{% ifchanged week.year %}
|
||||
{% for year in years %}
|
||||
<div>
|
||||
<h1>{{ year.year }}</h1>
|
||||
<div class="year-details-{{ year.year }}">
|
||||
{% for week in year.weeks %}
|
||||
{% if week.date == this_week %}
|
||||
<b>{{ week.title }}</b><br>
|
||||
{% else %}
|
||||
<a href="/_{{ week.date }}/">{{ week.title }}</a><br>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<h1>{{ week.year }}</h1>
|
||||
<div class="year-details-{{ week.year }}" {% if week.year != this_year %} style="display: none"{% endif %}>
|
||||
{% endifchanged %}
|
||||
{% if week.date == this_week %}
|
||||
<b>{{ week.title }}</b><br>
|
||||
{% else %}
|
||||
<a href="/_{{ week.date }}/">{{ week.title }}</a><br>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<script>
|
||||
document.querySelectorAll('.weeks h1').forEach(h1 => {
|
||||
h1.addEventListener('click', event => {
|
||||
|
|
Loading…
Reference in a new issue