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,13 +18,11 @@
|
||||||
</div>
|
</div>
|
||||||
{% if weeks %}
|
{% if weeks %}
|
||||||
<div class="weeks">
|
<div class="weeks">
|
||||||
|
{% for year in years %}
|
||||||
<div>
|
<div>
|
||||||
{% for week in weeks %}
|
<h1>{{ year.year }}</h1>
|
||||||
{% ifchanged week.year %}
|
<div class="year-details-{{ year.year }}">
|
||||||
</div>
|
{% for week in year.weeks %}
|
||||||
<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 %}
|
{% if week.date == this_week %}
|
||||||
<b>{{ week.title }}</b><br>
|
<b>{{ week.title }}</b><br>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -32,6 +30,8 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
<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