Skip to content

Commit

Permalink
Merge branch 'main' into pandoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdurbin committed Feb 21, 2024
2 parents 3705589 + 95304aa commit d257601
Show file tree
Hide file tree
Showing 29 changed files with 419 additions and 84 deletions.
4 changes: 2 additions & 2 deletions base-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ psycopg2-binary==2.8.6
python3-openid==3.2.0
python-decouple==3.4
# lxml used by BeautifulSoup.
lxml==4.6.3
lxml==4.9.2
cssselect==1.1.0
feedparser==6.0.8
beautifulsoup4==4.9.3
beautifulsoup4==4.11.2
icalendar==4.0.7
chardet==4.0.0
# TODO: We may drop 'django-imagekit' completely.
Expand Down
9 changes: 0 additions & 9 deletions blogs/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,3 @@ def test_blog_home(self):

latest = BlogEntry.objects.latest()
self.assertEqual(resp.context['latest_entry'], latest)

def test_blog_redirects(self):
"""
Test that when '/blog/' is hit, it redirects '/blogs/'
"""
response = self.client.get('/blog/')
self.assertRedirects(response,
'/blogs/',
status_code=301)
24 changes: 24 additions & 0 deletions config/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ http {
return 301 https://www.python.org/psf;
}

location ~ ^/community-landing/?(.*)$ {
return 301 https://www.python.org/community/;
}

location /doc/Summary {
return 301 http://legacy.python.org/doc/intros/summary;
}
Expand Down Expand Up @@ -204,6 +208,22 @@ http {
return 301 https://www.python.org/download/windows/;
}

location /download/ {
return 301 https://www.python.org/downloads/;
}

location /download/source/ {
return 301 https://www.python.org/downloads/source/;
}

location /download/mac/ {
return 301 https://www.python.org/downloads/macos/;
}

location /download/windows/ {
return 301 https://www.python.org/downloads/windows/;
}

location /Mirrors.html {
return 301 https://www.python.org/mirrors/;
}
Expand Down Expand Up @@ -292,6 +312,10 @@ http {
return 302 /blogs/;
}

location /blog/ {
return 301 https://python.org/blogs/;
}

location /static/ {
alias /app/static-root/;
add_header Cache-Control "max-age=604800, public"; # 604800 is 7 days
Expand Down
2 changes: 1 addition & 1 deletion downloads/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Meta(GenericResource.Meta):
'creator', 'last_modified_by',
'os', 'release', 'description', 'is_source', 'url', 'gpg_signature_file',
'md5_sum', 'filesize', 'download_button', 'sigstore_signature_file',
'sigstore_cert_file', 'sigstore_bundle_file',
'sigstore_cert_file', 'sigstore_bundle_file', 'sbom_spdx2_file',
]
filtering = {
'name': ('exact',),
Expand Down
18 changes: 18 additions & 0 deletions downloads/migrations/0010_releasefile_sbom_spdx2_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2024-01-12 21:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('downloads', '0009_releasefile_sigstore_bundle_file'),
]

operations = [
migrations.AddField(
model_name='releasefile',
name='sbom_spdx2_file',
field=models.URLField(blank=True, help_text='SPDX-2 SBOM URL', verbose_name='SPDX-2 SBOM URL'),
),
]
3 changes: 3 additions & 0 deletions downloads/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ class ReleaseFile(ContentManageable, NameSlugModel):
sigstore_bundle_file = models.URLField(
"Sigstore Bundle URL", blank=True, help_text="Sigstore Bundle URL"
)
sbom_spdx2_file = models.URLField(
"SPDX-2 SBOM URL", blank=True, help_text="SPDX-2 SBOM URL"
)
md5_sum = models.CharField('MD5 Sum', max_length=200, blank=True)
filesize = models.IntegerField(default=0)
download_button = models.BooleanField(default=False, help_text="Use for the supernav download button for this OS")
Expand Down
1 change: 1 addition & 0 deletions downloads/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ class Meta:
'sigstore_signature_file',
'sigstore_cert_file',
'sigstore_bundle_file',
'sbom_spdx2_file',
)
39 changes: 39 additions & 0 deletions downloads/templatetags/download_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,42 @@ 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 has_sbom(files):
return any(f.sbom_spdx2_file for f in files)


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

# Put Windows files in preferred order
files = list(files)
windows_files = []
other_files = []
for preferred in (
'Windows installer (64-bit)',
'Windows installer (32-bit)',
'Windows installer (ARM64)',
'Windows help file',
'Windows embeddable package (64-bit)',
'Windows embeddable package (32-bit)',
'Windows embeddable package (ARM64)',
):
for file in files:
if file.name == preferred:
windows_files.append(file)
files.remove(file)
break

# Then append any remaining Windows files
for file in files:
if file.name.startswith('Windows'):
windows_files.append(file)
else:
other_files.append(file)

return other_files + windows_files
1 change: 1 addition & 0 deletions downloads/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def setUp(self):
is_source=True,
description='Gzipped source',
url='ftp/python/2.7.5/Python-2.7.5.tgz',
filesize=12345678,
)

self.draft_release = Release.objects.create(
Expand Down
3 changes: 3 additions & 0 deletions downloads/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def test_download_release_detail(self):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

with self.subTest("Release file sizes should be human-readable"):
self.assertInHTML("<td>11.8 MB</td>", response.content.decode())

url = reverse('download:download_release_detail', kwargs={'release_slug': 'fake_slug'})
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
Expand Down
4 changes: 2 additions & 2 deletions fixtures/boxes.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@
"created": "2013-10-28T19:27:20.963Z",
"updated": "2022-01-05T15:42:59.645Z",
"label": "widget-use-python-for",
"content": "<h2 class=\"widget-title\"><span aria-hidden=\"true\" class=\"icon-python\"></span>Use Python for&hellip;</h2>\r\n<p class=\"give-me-more\"><a href=\"/about/apps\" title=\"More Applications\">More</a></p>\r\n\r\n<ul class=\"menu\">\r\n <li><b>Web Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.djangoproject.com/\">Django</a>, <a class=\"tag\" href=\"http://www.pylonsproject.org/\">Pyramid</a>, <a class=\"tag\" href=\"http://bottlepy.org\">Bottle</a>, <a class=\"tag\" href=\"http://tornadoweb.org\">Tornado</a>, <a href=\"http://flask.pocoo.org/\" class=\"tag\">Flask</a>, <a class=\"tag\" href=\"http://www.web2py.com/\">web2py</a></span></li>\r\n <li><b>GUI Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://wiki.python.org/moin/TkInter\">tkInter</a>, <a class=\"tag\" href=\"https://wiki.gnome.org/Projects/PyGObject\">PyGObject</a>, <a class=\"tag\" href=\"http://www.riverbankcomputing.co.uk/software/pyqt/intro\">PyQt</a>, <a class=\"tag\" href=\"https://wiki.qt.io/PySide\">PySide</a>, <a class=\"tag\" href=\"https://kivy.org/\">Kivy</a>, <a class=\"tag\" href=\"http://www.wxpython.org/\">wxPython</a></span></li>\r\n <li><b>Scientific and Numeric</b>:\r\n <span class=\"tag-wrapper\">\r\n<a class=\"tag\" href=\"http://www.scipy.org\">SciPy</a>, <a class=\"tag\" href=\"http://pandas.pydata.org/\">Pandas</a>, <a href=\"http://ipython.org\" class=\"tag\">IPython</a></span></li>\r\n <li><b>Software Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://buildbot.net/\">Buildbot</a>, <a class=\"tag\" href=\"http://trac.edgewall.org/\">Trac</a>, <a class=\"tag\" href=\"http://roundup.sourceforge.net/\">Roundup</a></span></li>\r\n <li><b>System Administration</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.ansible.com\">Ansible</a>, <a class=\"tag\" href=\"https://saltproject.io\">Salt</a>, <a class=\"tag\" href=\"https://www.openstack.org\">OpenStack</a>, <a class=\"tag\" href=\"https://xon.sh\">xonsh</a></span></li>\r\n</ul>",
"content": "<h2 class=\"widget-title\"><span aria-hidden=\"true\" class=\"icon-python\"></span>Use Python for&hellip;</h2>\r\n<p class=\"give-me-more\"><a href=\"/about/apps\" title=\"More Applications\">More</a></p>\r\n\r\n<ul class=\"menu\">\r\n <li><b>Web Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.djangoproject.com/\">Django</a>, <a class=\"tag\" href=\"http://www.pylonsproject.org/\">Pyramid</a>, <a class=\"tag\" href=\"http://bottlepy.org\">Bottle</a>, <a class=\"tag\" href=\"http://tornadoweb.org\">Tornado</a>, <a href=\"http://flask.pocoo.org/\" class=\"tag\">Flask</a>, <a class=\"tag\" href=\"http://www.web2py.com/\">web2py</a></span></li>\r\n <li><b>GUI Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://wiki.python.org/moin/TkInter\">tkInter</a>, <a class=\"tag\" href=\"https://wiki.gnome.org/Projects/PyGObject\">PyGObject</a>, <a class=\"tag\" href=\"http://www.riverbankcomputing.co.uk/software/pyqt/intro\">PyQt</a>, <a class=\"tag\" href=\"https://wiki.qt.io/PySide\">PySide</a>, <a class=\"tag\" href=\"https://kivy.org/\">Kivy</a>, <a class=\"tag\" href=\"http://www.wxpython.org/\">wxPython</a>, <a class=\"tag\" href=\"https://dearpygui.readthedocs.io/en/latest/\">DearPyGui</a></span></li>\r\n <li><b>Scientific and Numeric</b>:\r\n <span class=\"tag-wrapper\">\r\n<a class=\"tag\" href=\"http://www.scipy.org\">SciPy</a>, <a class=\"tag\" href=\"http://pandas.pydata.org/\">Pandas</a>, <a href=\"http://ipython.org\" class=\"tag\">IPython</a></span></li>\r\n <li><b>Software Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://buildbot.net/\">Buildbot</a>, <a class=\"tag\" href=\"http://trac.edgewall.org/\">Trac</a>, <a class=\"tag\" href=\"http://roundup.sourceforge.net/\">Roundup</a></span></li>\r\n <li><b>System Administration</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.ansible.com\">Ansible</a>, <a class=\"tag\" href=\"https://saltproject.io\">Salt</a>, <a class=\"tag\" href=\"https://www.openstack.org\">OpenStack</a>, <a class=\"tag\" href=\"https://xon.sh\">xonsh</a></span></li>\r\n</ul>",
"content_markup_type": "html",
"_content_rendered": "<h2 class=\"widget-title\"><span aria-hidden=\"true\" class=\"icon-python\"></span>Use Python for&hellip;</h2>\r\n<p class=\"give-me-more\"><a href=\"/about/apps\" title=\"More Applications\">More</a></p>\r\n\r\n<ul class=\"menu\">\r\n <li><b>Web Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.djangoproject.com/\">Django</a>, <a class=\"tag\" href=\"http://www.pylonsproject.org/\">Pyramid</a>, <a class=\"tag\" href=\"http://bottlepy.org\">Bottle</a>, <a class=\"tag\" href=\"http://tornadoweb.org\">Tornado</a>, <a href=\"http://flask.pocoo.org/\" class=\"tag\">Flask</a>, <a class=\"tag\" href=\"http://www.web2py.com/\">web2py</a></span></li>\r\n <li><b>GUI Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://wiki.python.org/moin/TkInter\">tkInter</a>, <a class=\"tag\" href=\"https://wiki.gnome.org/Projects/PyGObject\">PyGObject</a>, <a class=\"tag\" href=\"http://www.riverbankcomputing.co.uk/software/pyqt/intro\">PyQt</a>, <a class=\"tag\" href=\"https://wiki.qt.io/PySide\">PySide</a>, <a class=\"tag\" href=\"https://kivy.org/\">Kivy</a>, <a class=\"tag\" href=\"http://www.wxpython.org/\">wxPython</a></span></li>\r\n <li><b>Scientific and Numeric</b>:\r\n <span class=\"tag-wrapper\">\r\n<a class=\"tag\" href=\"http://www.scipy.org\">SciPy</a>, <a class=\"tag\" href=\"http://pandas.pydata.org/\">Pandas</a>, <a href=\"http://ipython.org\" class=\"tag\">IPython</a></span></li>\r\n <li><b>Software Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://buildbot.net/\">Buildbot</a>, <a class=\"tag\" href=\"http://trac.edgewall.org/\">Trac</a>, <a class=\"tag\" href=\"http://roundup.sourceforge.net/\">Roundup</a></span></li>\r\n <li><b>System Administration</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.ansible.com\">Ansible</a>, <a class=\"tag\" href=\"https://saltproject.io\">Salt</a>, <a class=\"tag\" href=\"https://www.openstack.org\">OpenStack</a>, <a class=\"tag\" href=\"https://xon.sh\">xonsh</a></span></li>\r\n</ul>"
"_content_rendered": "<h2 class=\"widget-title\"><span aria-hidden=\"true\" class=\"icon-python\"></span>Use Python for&hellip;</h2>\r\n<p class=\"give-me-more\"><a href=\"/about/apps\" title=\"More Applications\">More</a></p>\r\n\r\n<ul class=\"menu\">\r\n <li><b>Web Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.djangoproject.com/\">Django</a>, <a class=\"tag\" href=\"http://www.pylonsproject.org/\">Pyramid</a>, <a class=\"tag\" href=\"http://bottlepy.org\">Bottle</a>, <a class=\"tag\" href=\"http://tornadoweb.org\">Tornado</a>, <a href=\"http://flask.pocoo.org/\" class=\"tag\">Flask</a>, <a class=\"tag\" href=\"http://www.web2py.com/\">web2py</a></span></li>\r\n <li><b>GUI Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://wiki.python.org/moin/TkInter\">tkInter</a>, <a class=\"tag\" href=\"https://wiki.gnome.org/Projects/PyGObject\">PyGObject</a>, <a class=\"tag\" href=\"http://www.riverbankcomputing.co.uk/software/pyqt/intro\">PyQt</a>, <a class=\"tag\" href=\"https://wiki.qt.io/PySide\">PySide</a>, <a class=\"tag\" href=\"https://kivy.org/\">Kivy</a>, <a class=\"tag\" href=\"http://www.wxpython.org/\">wxPython</a>, <a class=\"tag\" href=\"https://dearpygui.readthedocs.io/en/latest/\">DearPyGui</a></span></li>\r\n <li><b>Scientific and Numeric</b>:\r\n <span class=\"tag-wrapper\">\r\n<a class=\"tag\" href=\"http://www.scipy.org\">SciPy</a>, <a class=\"tag\" href=\"http://pandas.pydata.org/\">Pandas</a>, <a href=\"http://ipython.org\" class=\"tag\">IPython</a></span></li>\r\n <li><b>Software Development</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://buildbot.net/\">Buildbot</a>, <a class=\"tag\" href=\"http://trac.edgewall.org/\">Trac</a>, <a class=\"tag\" href=\"http://roundup.sourceforge.net/\">Roundup</a></span></li>\r\n <li><b>System Administration</b>:\r\n <span class=\"tag-wrapper\"><a class=\"tag\" href=\"http://www.ansible.com\">Ansible</a>, <a class=\"tag\" href=\"https://saltproject.io\">Salt</a>, <a class=\"tag\" href=\"https://www.openstack.org\">OpenStack</a>, <a class=\"tag\" href=\"https://xon.sh\">xonsh</a></span></li>\r\n</ul>"
}
},
{
Expand Down
9 changes: 1 addition & 8 deletions pydotorg/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls.static import static
from django.urls import path, re_path
from django.views.generic.base import TemplateView, RedirectView
from django.views.generic.base import TemplateView
from django.conf import settings

from cms.views import custom_404
Expand All @@ -24,18 +24,11 @@
# python section landing pages
path('about/', TemplateView.as_view(template_name="python/about.html"), name='about'),

# Redirect old download links to new downloads pages
path('download/', RedirectView.as_view(url='https://www.python.org/downloads/', permanent=True)),
path('download/source/', RedirectView.as_view(url='https://www.python.org/downloads/source/', permanent=True)),
path('download/mac/', RedirectView.as_view(url='https://www.python.org/downloads/macos/', permanent=True)),
path('download/windows/', RedirectView.as_view(url='https://www.python.org/downloads/windows/', permanent=True)),

# duplicated downloads to getit to bypass China's firewall. See
# https://github.com/python/pythondotorg/issues/427 for more info.
path('getit/', include('downloads.urls', namespace='getit')),
path('downloads/', include('downloads.urls', namespace='download')),
path('doc/', views.DocumentationIndexView.as_view(), name='documentation'),
path('blog/', RedirectView.as_view(url='/blogs/', permanent=True)),
path('blogs/', include('blogs.urls')),
path('inner/', TemplateView.as_view(template_name="python/inner.html"), name='inner'),

Expand Down
10 changes: 7 additions & 3 deletions sponsors/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,13 @@ def has_delete_permission(self, request, obj=None):
return True
return obj.open_for_editing

def get_queryset(self, *args, **kwargs):
qs = super().get_queryset(*args, **kwargs)
return qs.select_related("sponsorship_benefit__program", "program")
def get_queryset(self, request):
#filters the available benefits by the benefits for the year of the sponsorship
match = request.resolver_match
sponsorship = self.parent_model.objects.get(pk=match.kwargs["object_id"])
year = sponsorship.year

return super().get_queryset(request).filter(sponsorship_benefit__year=year)


class TargetableEmailBenefitsFilter(admin.SimpleListFilter):
Expand Down
17 changes: 16 additions & 1 deletion sponsors/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ class SponsorshipApplicationForm(forms.Form):
help_text="For promotion of your sponsorship on social media.",
required=False,
)
linked_in_page_url = forms.URLField(
label="LinkedIn page URL",
help_text="URL for your LinkedIn page.",
required=False,
)
web_logo = forms.ImageField(
label="Sponsor web logo",
help_text="For display on our sponsor webpage. High resolution PNG or JPG, smallest dimension no less than 256px",
Expand Down Expand Up @@ -253,10 +258,17 @@ class SponsorshipApplicationForm(forms.Form):
state = forms.CharField(
label="State/Province/Region", max_length=64, required=False
)
state_of_incorporation = forms.CharField(
label="State of incorporation", help_text="US only, If different than mailing address", max_length=64, required=False
)
postal_code = forms.CharField(
label="Zip/Postal Code", max_length=64, required=False
)
country = CountryField().formfield(required=False)
country = CountryField().formfield(required=False, help_text="For mailing/contact purposes")

country_of_incorporation = CountryField().formfield(
label="Country of incorporation", help_text="For contractual purposes", required=False
)

def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user", None)
Expand Down Expand Up @@ -372,7 +384,10 @@ def save(self):
description=self.cleaned_data.get("description", ""),
landing_page_url=self.cleaned_data.get("landing_page_url", ""),
twitter_handle=self.cleaned_data["twitter_handle"],
linked_in_page_url=self.cleaned_data["linked_in_page_url"],
print_logo=self.cleaned_data.get("print_logo"),
country_of_incorporation=self.cleaned_data.get("country_of_incorporation", ""),
state_of_incorporation=self.cleaned_data.get("state_of_incorporation", ""),
)
contacts = [f.save(commit=False) for f in self.contacts_formset.forms]
for contact in contacts:
Expand Down
20 changes: 12 additions & 8 deletions sponsors/management/commands/create_pycon_vouchers_for_sponsors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@
)

BENEFITS = {
121: {
"internal_name": "full_conference_passes_2023_code",
183: {
"internal_name": "full_conference_passes_code_2024",
"voucher_type": "SPNS_COMP_",
},
139: {
"internal_name": "expo_hall_only_passes_2023_code",
201: {
"internal_name": "expo_hall_only_passes_code_2024",
"voucher_type": "SPNS_EXPO_COMP_",
},
148: {
"internal_name": "additional_full_conference_passes_2023_code",
208: {
"internal_name": "additional_full_conference_passes_code_2024",
"voucher_type": "SPNS_ADDL_DISC_REG_",
},
166: {
"internal_name": "online_only_conference_passes_2023_code",
225: {
"internal_name": "online_only_conference_passes_2024",
"voucher_type": "SPNS_ONLINE_COMP_",
},
237: {
"internal_name": "additional_expo_hall_only_passes_2024",
"voucher_type": "SPNS_EXPO_DISC_",
},
}


Expand Down
Loading

0 comments on commit d257601

Please sign in to comment.