Skip to content

Commit ba1d3fe

Browse files
authored
Add featured downloads (#2805)
1 parent 61f0c9a commit ba1d3fe

File tree

4 files changed

+117
-2
lines changed

4 files changed

+117
-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

static/sass/style.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,50 @@ table tfoot {
21132113
.download-widget p:last-child a {
21142114
white-space: nowrap; }
21152115

2116+
.featured-downloads-list {
2117+
display: flex;
2118+
flex-wrap: wrap;
2119+
gap: 1.5em;
2120+
justify-content: center;
2121+
margin-bottom: 2em; }
2122+
2123+
.featured-download-box {
2124+
background-color: #f2f4f6;
2125+
border: 1px solid #caccce;
2126+
border-radius: 5px;
2127+
display: flex;
2128+
flex: 1 1 300px;
2129+
flex-direction: column;
2130+
min-width: 250px;
2131+
max-width: 400px;
2132+
padding: 1.25em; }
2133+
.featured-download-box h3 {
2134+
margin-top: 0; }
2135+
.featured-download-box .button {
2136+
background-color: #ffd343;
2137+
*zoom: 1;
2138+
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFFFDF76', endColorstr='#FFFFD343');
2139+
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(10%, #ffdf76), color-stop(90%, #ffd343));
2140+
background-image: -webkit-linear-gradient(#ffdf76 10%, #ffd343 90%);
2141+
background-image: -moz-linear-gradient(#ffdf76 10%, #ffd343 90%);
2142+
background-image: -o-linear-gradient(#ffdf76 10%, #ffd343 90%);
2143+
background-image: linear-gradient(#ffdf76 10%, #ffd343 90%);
2144+
border: 1px solid #dca900;
2145+
white-space: normal; }
2146+
.featured-download-box .button:hover, .featured-download-box .button:active {
2147+
background-color: inherit;
2148+
background-color: #ffd343;
2149+
*zoom: 1;
2150+
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFFFEBA9', endColorstr='#FFFFD343');
2151+
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(10%, #ffeba9), color-stop(90%, #ffd343));
2152+
background-image: -webkit-linear-gradient(#ffeba9 10%, #ffd343 90%);
2153+
background-image: -moz-linear-gradient(#ffeba9 10%, #ffd343 90%);
2154+
background-image: -o-linear-gradient(#ffeba9 10%, #ffd343 90%);
2155+
background-image: linear-gradient(#ffeba9 10%, #ffd343 90%); }
2156+
.featured-download-box .download-buttons {
2157+
margin-bottom: 0;
2158+
text-align: center; }
2159+
21162160
.time-posted {
21172161
display: block;
21182162
font-size: 0.875em;

static/sass/style.scss

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,46 @@ $colors: $blue, $psf, $yellow, $green, $purple, $red;
10981098
p:last-child a { white-space: nowrap; }
10991099
}
11001100

1101+
.featured-downloads-list {
1102+
display: flex;
1103+
flex-wrap: wrap;
1104+
gap: 1.5em;
1105+
justify-content: center;
1106+
margin-bottom: 2em;
1107+
}
1108+
1109+
.featured-download-box {
1110+
background-color: $grey-lighterest;
1111+
border: 1px solid $default-border-color;
1112+
border-radius: 5px;
1113+
display: flex;
1114+
flex: 1 1 300px;
1115+
flex-direction: column;
1116+
min-width: 250px;
1117+
max-width: 400px;
1118+
padding: 1.25em;
1119+
1120+
h3 {
1121+
margin-top: 0;
1122+
}
1123+
1124+
.button {
1125+
@include vertical-gradient( lighten($yellow, 10%), $yellow );
1126+
border: 1px solid darken($yellow, 20%);
1127+
white-space: normal;
1128+
1129+
&:hover, &:active {
1130+
background-color: inherit;
1131+
@include vertical-gradient( lighten($yellow, 20%), $yellow );
1132+
}
1133+
}
1134+
1135+
.download-buttons {
1136+
margin-bottom: 0;
1137+
text-align: center;
1138+
}
1139+
}
1140+
11011141
.documentation-widget { }
11021142

11031143
.jobs-widget { }

templates/downloads/release_detail.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,26 @@ <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+
{% if f.os.slug == 'windows' and latest_pymanager and release.is_version_at_least_3_5 %}
54+
<a class="button" href="https://www.python.org/downloads/latest/pymanager/">Download Python install manager</a>
55+
{% else %}
56+
<a class="button" href="{{ f.url }}">Download {{ f.name }}</a>
57+
{% endif %}
58+
</p>
59+
</div>
60+
{% endfor %}
61+
</div>
62+
{% endif %}
63+
4764
<table>
4865
<thead>
4966
<tr>

0 commit comments

Comments
 (0)