Skip to content

Commit f3fa1fc

Browse files
authored
Prioritise 64-bit downloads over 32-bit (#2311)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent a4990b7 commit f3fa1fc

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

downloads/templatetags/download_tags.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,37 @@ def has_sigstore_materials(files):
1919
@register.filter
2020
def has_sbom(files):
2121
return any(f.sbom_spdx2_file for f in files)
22+
23+
24+
@register.filter
25+
def sort_windows(files):
26+
if not files:
27+
return files
28+
29+
# Put Windows files in preferred order
30+
files = list(files)
31+
windows_files = []
32+
other_files = []
33+
for preferred in (
34+
'Windows installer (64-bit)',
35+
'Windows installer (32-bit)',
36+
'Windows installer (ARM64)',
37+
'Windows help file',
38+
'Windows embeddable package (64-bit)',
39+
'Windows embeddable package (32-bit)',
40+
'Windows embeddable package (ARM64)',
41+
):
42+
for file in files:
43+
if file.name == preferred:
44+
windows_files.append(file)
45+
files.remove(file)
46+
break
47+
48+
# Then append any remaining Windows files
49+
for file in files:
50+
if file.name.startswith('Windows'):
51+
windows_files.append(file)
52+
else:
53+
other_files.append(file)
54+
55+
return other_files + windows_files

templates/downloads/os_list.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends "downloads/base.html" %}
22
{% load boxes %}
33
{% load sitetree %}
4+
{% load sort_windows from download_tags %}
45

56
{% block body_attributes %}class="python download"{% endblock %}
67

@@ -45,7 +46,7 @@ <h2>Stable Releases</h2>
4546
{% endif %}
4647
{% endif %}
4748
<ul>
48-
{% for f in r.files.all %}
49+
{% for f in r.files.all|sort_windows %}
4950
<li>Download <a href="{{ f.url }}">{{ f.name }}</a></li>
5051
{% empty %}
5152
<li>No files for this release.</li>
@@ -63,7 +64,7 @@ <h2>Pre-releases</h2>
6364
<li>
6465
<a href="{{ r.get_absolute_url }}">{{ r.name }} - {{ r.release_date|date }}</a>
6566
<ul>
66-
{% for f in r.files.all %}
67+
{% for f in r.files.all|sort_windows %}
6768
<li>Download <a href="{{ f.url }}">{{ f.name }}</a></li>
6869
{% empty %}
6970
<li>No files for this release.</li>

templates/downloads/release_detail.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{% load sitetree %}
44
{% load has_sigstore_materials from download_tags %}
55
{% load has_sbom from download_tags %}
6+
{% load sort_windows from download_tags %}
67

78
{% block body_attributes %}class="python downloads"{% endblock %}
89

@@ -60,7 +61,7 @@ <h1 class="page-title">Files</h1>
6061
</tr>
6162
</thead>
6263
<tbody>
63-
{% for f in release_files %}
64+
{% for f in release_files|sort_windows %}
6465
<tr>
6566
<td><a href="{{ f.url }}">{{ f.name }}</a></td>
6667
<td>{{ f.os.name }}</td>

0 commit comments

Comments
 (0)