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'))
|
week = int(date.strftime('%W'))
|
||||||
year = int(year)
|
year = int(year)
|
||||||
archive_week = archive.filter(year=year, week=week).order_by('published')
|
archive_week = archive.filter(year=year, week=week).order_by('published')
|
||||||
|
years = {}
|
||||||
context['weeks'] = get_weeks(archive)
|
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_week'] = date.strftime('%Y-%m-%d')
|
||||||
context['this_year'] = date.strftime('%Y')
|
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']).first()
|
||||||
|
|
|
@ -18,20 +18,20 @@
|
||||||
</div>
|
</div>
|
||||||
{% if weeks %}
|
{% if weeks %}
|
||||||
<div class="weeks">
|
<div class="weeks">
|
||||||
<div>
|
{% for year in years %}
|
||||||
{% for week in weeks %}
|
<div>
|
||||||
{% ifchanged week.year %}
|
<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>
|
</div>
|
||||||
<h1>{{ week.year }}</h1>
|
</div>
|
||||||
<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 %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
|
||||||
<script>
|
<script>
|
||||||
document.querySelectorAll('.weeks h1').forEach(h1 => {
|
document.querySelectorAll('.weeks h1').forEach(h1 => {
|
||||||
h1.addEventListener('click', event => {
|
h1.addEventListener('click', event => {
|
||||||
|
|
Loading…
Reference in a new issue