Skip to content

Commit

Permalink
Prioritise 64-bit downloads over 32-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 16, 2023
1 parent c4ee749 commit 0403ca1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions downloads/templatetags/download_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,21 @@ def has_sigstore_materials(files):
f.sigstore_bundle_file or f.sigstore_cert_file or f.sigstore_signature_file
for f in files
)


@register.filter
def prioritise_64bit_over_32bit(files):
if not files:
return files

# Put 64-bit files before 32-bit
new = []
previous = files[0]
for i, current in enumerate(files):
if i >= 1 and '(64-bit)' in current.name and '(32-bit)' in previous.name:
new.insert(-1, current)
else:
new.append(current)
previous = current

return new
5 changes: 3 additions & 2 deletions templates/downloads/os_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "downloads/base.html" %}
{% load boxes %}
{% load sitetree %}
{% load prioritise_64bit_over_32bit from download_tags %}

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

Expand Down Expand Up @@ -45,7 +46,7 @@ <h2>Stable Releases</h2>
{% endif %}
{% endif %}
<ul>
{% for f in r.files.all %}
{% for f in r.files.all|prioritise_64bit_over_32bit %}
<li>Download <a href="{{ f.url }}">{{ f.name }}</a></li>
{% empty %}
<li>No files for this release.</li>
Expand All @@ -63,7 +64,7 @@ <h2>Pre-releases</h2>
<li>
<a href="{{ r.get_absolute_url }}">{{ r.name }} - {{ r.release_date|date }}</a>
<ul>
{% for f in r.files.all %}
{% for f in r.files.all|prioritise_64bit_over_32bit %}
<li>Download <a href="{{ f.url }}">{{ f.name }}</a></li>
{% empty %}
<li>No files for this release.</li>
Expand Down
3 changes: 2 additions & 1 deletion templates/downloads/release_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load boxes %}
{% load sitetree %}
{% load has_sigstore_materials from download_tags %}
{% load prioritise_64bit_over_32bit from download_tags %}

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

Expand Down Expand Up @@ -56,7 +57,7 @@ <h1 class="page-title">Files</h1>
</tr>
</thead>
<tbody>
{% for f in release_files %}
{% for f in release_files|prioritise_64bit_over_32bit %}
<tr>
<td><a href="{{ f.url }}">{{ f.name }}</a></td>
<td>{{ f.os.name }}</td>
Expand Down

0 comments on commit 0403ca1

Please sign in to comment.