Skip to content

Commit fa78a8a

Browse files
authored
Merge branch 'main' into django-5.2
2 parents 3e7d9a1 + 895a7e1 commit fa78a8a

8 files changed

Lines changed: 49 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
migrations:
7-
if: github.event_name != 'push' || github.event.repository.fork == true
7+
if: github.event_name != 'push' || github.event.repository.fork == true || github.ref == 'refs/heads/main'
88
runs-on: ubuntu-latest
99
services:
1010
postgres:
@@ -40,7 +40,7 @@ jobs:
4040
DATABASE_URL: postgres://postgres:postgres@localhost:5432/pythonorg
4141

4242
test:
43-
if: github.event_name != 'push' || github.event.repository.fork == true
43+
if: github.event_name != 'push' || github.event.repository.fork == true || github.ref == 'refs/heads/main'
4444
runs-on: ubuntu-latest
4545
services:
4646
postgres:
@@ -92,4 +92,4 @@ jobs:
9292
DATABASE_URL: postgres://postgres:postgres@localhost:5432/pythonorg
9393

9494
- name: Check coverage
95-
run: coverage report -m --fail-under=75
95+
run: coverage report -m --fail-under=75

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
collectstatic:
7-
if: github.event_name != 'push' || github.event.repository.fork == true
7+
if: github.event_name != 'push' || github.event.repository.fork == true || github.ref == 'refs/heads/main'
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Check out repository

downloads/templatetags/download_tags.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ def has_sbom(files):
8080
return any(f.sbom_spdx2_file for f in files)
8181

8282

83+
@register.filter
84+
def has_md5(files):
85+
return any(f.md5_sum for f in files)
86+
87+
88+
@register.filter
89+
def has_sha256(files):
90+
return any(f.sha256_sum for f in files)
91+
92+
8393
@register.filter
8494
def sort_windows(files):
8595
if not files:

downloads/views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,17 @@ def item_pubdate(self, item: Release) -> datetime | None:
267267
return timezone.make_aware(item.release_date)
268268
return item.release_date
269269
return None
270+
271+
272+
class ReleaseEditButton(TemplateView):
273+
"""Render the release edit button (shown only to staff users).
274+
275+
This endpoint is not cached, allowing the edit button to appear
276+
for staff users even when the release page itself is cached.
277+
"""
278+
template_name = "downloads/release_edit_button.html"
279+
280+
def get_context_data(self, **kwargs):
281+
context = super().get_context_data(**kwargs)
282+
context["release_pk"] = self.kwargs["pk"]
283+
return context

pydotorg/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.conf import settings
99

1010
from cms.views import custom_404
11+
from downloads.views import ReleaseEditButton
1112
from users.views import HoneypotSignupView, CustomPasswordChangeView
1213

1314
from . import views, urls_api
@@ -19,6 +20,7 @@
1920
path('', views.IndexView.as_view(), name='home'),
2021
re_path(r'^_health/?', views.health, name='health'),
2122
path('authenticated', views.AuthenticatedView.as_view(), name='authenticated'),
23+
path('release-edit-button/<int:pk>', ReleaseEditButton.as_view(), name='release_edit_button'),
2224
path('humans.txt', TemplateView.as_view(template_name='humans.txt', content_type='text/plain')),
2325
path('robots.txt', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
2426
path('funding.json', views.serve_funding_json, name='funding_json'),

templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
<div id="touchnav-wrapper">
130130

131131
<div id="nojs" class="do-not-print">
132-
<p><strong>Notice:</strong> While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience. </p>
132+
<p><strong>Notice:</strong> This page displays a fallback because interactive scripts did not run. Possible causes include disabled JavaScript or failure to load scripts or stylesheets.</p>
133133
</div>
134134

135135
<!-- Sister Site Links -->

templates/downloads/release_detail.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
{% load has_gpg from download_tags %}
55
{% load has_sigstore_materials from download_tags %}
66
{% load has_sbom from download_tags %}
7+
{% load has_md5 from download_tags %}
8+
{% load has_sha256 from download_tags %}
79
{% load sort_windows from download_tags %}
810
{% load get_eol_info from download_tags %}
911

@@ -22,9 +24,7 @@
2224

2325
{% block content %}
2426
<article class="text">
25-
{% if request.user.is_staff %}
26-
<a role="button" class="button" href="{% url 'admin:downloads_release_change' release.pk %}">Edit this release</a>
27-
{% endif %}
27+
<span data-html-include="{% url 'release_edit_button' release.pk %}"></span>
2828

2929
<header class="article-header">
3030
<h1 class="page-title">{{ release.name }}</h1>
@@ -85,11 +85,9 @@ <h3>{{ f.os.name }}</h3>
8585
<thead>
8686
<tr>
8787
<th>Version</th>
88-
<th>Operating System</th>
88+
<th>Operating system</th>
8989
<th>Description</th>
90-
<th>MD5 Checksum</th>
91-
<th>SHA256 Checksum</th>
92-
<th>File Size</th>
90+
<th>File size</th>
9391
{% if release_files|has_sigstore_materials %}
9492
<th colspan="2"><a href="https://www.python.org/download/sigstore/">Sigstore</a></th>
9593
{% endif %}
@@ -99,6 +97,11 @@ <h3>{{ f.os.name }}</h3>
9997
{% if release_files|has_gpg %}
10098
<th><a href="https://www.python.org/downloads/#gpg">GPG</a></th>
10199
{% endif %}
100+
{% if release_files|has_sha256 %}
101+
<th>SHA-256 checksum</th>
102+
{% elif release_files|has_md5 %}
103+
<th>MD5 checksum</th>
104+
{% endif %}
102105
</tr>
103106
</thead>
104107
<tbody>
@@ -107,8 +110,6 @@ <h3>{{ f.os.name }}</h3>
107110
<td><a href="{{ f.url }}">{{ f.name }}</a></td>
108111
<td>{{ f.os.name }}</td>
109112
<td>{{ f.description }}</td>
110-
<td>{{ f.md5_sum }}</td>
111-
<td>{{ f.sha256_sum|default:"n/a" }}</td>
112113
<td>{{ f.filesize|filesizeformat }}</td>
113114
{% if release_files|has_sigstore_materials %}
114115
{% if f.sigstore_bundle_file %}
@@ -124,6 +125,11 @@ <h3>{{ f.os.name }}</h3>
124125
{% if release_files|has_gpg %}
125126
<td>{% if f.gpg_signature_file %}<a href="{{ f.gpg_signature_file }}">SIG</a>{% endif %}</td>
126127
{% endif %}
128+
{% if release_files|has_sha256 %}
129+
<td>{{ f.sha256_sum }}</td>
130+
{% elif release_files|has_md5 %}
131+
<td>{{ f.md5_sum }}</td>
132+
{% endif %}
127133
</tr>
128134
{% endfor %}
129135
</tbody>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% if request.user.is_staff %}
2+
<a role="button" class="button" href="{% url 'admin:downloads_release_change' release_pk %}">Edit this release</a>
3+
{% endif %}

0 commit comments

Comments
 (0)