Skip to content

Commit 0211593

Browse files
committed
Add featured downloads
1 parent 323a2ba commit 0211593

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

downloads/views.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from datetime import datetime
44

5-
from django.db.models import Prefetch
5+
from django.db.models import Case, IntegerField, Prefetch, When
66
from django.urls import reverse
77
from django.utils import timezone
88
from django.views.generic import DetailView, TemplateView, ListView, RedirectView
@@ -157,6 +157,20 @@ def get_object(self):
157157
def get_context_data(self, **kwargs):
158158
context = super().get_context_data(**kwargs)
159159

160+
# Add featured files (files with download_button=True)
161+
# Order: macOS first, Windows second, Source last
162+
context['featured_files'] = self.object.files.filter(
163+
download_button=True
164+
).annotate(
165+
os_order=Case(
166+
When(os__slug='macos', then=1),
167+
When(os__slug='windows', then=2),
168+
When(os__slug='source', then=3),
169+
default=4,
170+
output_field=IntegerField(),
171+
)
172+
).order_by('os_order')
173+
160174
# Manually add release files for better ordering
161175
context['release_files'] = []
162176

templates/downloads/release_detail.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,22 @@ <h1 class="page-title">{{ release.name }}</h1>
4141
{% endif %}
4242

4343
<header class="article-header">
44-
<h1 class="page-title">Files</h1>
44+
<h2 class="page-title">Files</h2>
4545
</header>
4646

47+
{% if featured_files %}
48+
<div class="featured-downloads-list">
49+
{% for f in featured_files %}
50+
<div class="featured-download-box">
51+
<h3>{{ f.os.name }}</h3>
52+
<p class="download-buttons">
53+
<a class="button" href="{{ f.url }}">Download {{ f.name }}</a>
54+
</p>
55+
</div>
56+
{% endfor %}
57+
</div>
58+
{% endif %}
59+
4760
<table>
4861
<thead>
4962
<tr>

0 commit comments

Comments
 (0)