diff --git a/fixtures/boxes.json b/fixtures/boxes.json index f7dbeb15e..b0e965011 100644 --- a/fixtures/boxes.json +++ b/fixtures/boxes.json @@ -654,9 +654,9 @@ "created": "2014-11-13T21:49:22.048Z", "updated": "2021-07-29T21:40:21.030Z", "label": "download-dev", - "content": "

Information about specific ports, and developer info

\r\n\r\n", + "content": "

Information about specific ports, and developer info

\r\n\r\n", "content_markup_type": "html", - "_content_rendered": "

Information about specific ports, and developer info

\r\n\r\n" + "_content_rendered": "

Information about specific ports, and developer info

\r\n\r\n" } }, { diff --git a/fixtures/sitetree_menus.json b/fixtures/sitetree_menus.json index 70ad3fc7c..f394233ee 100644 --- a/fixtures/sitetree_menus.json +++ b/fixtures/sitetree_menus.json @@ -685,7 +685,7 @@ "fields": { "title": "PEP Index", "hint": "", - "url": "http://python.org/dev/peps/", + "url": "https://peps.python.org", "urlaspattern": false, "tree": 1, "hidden": false, diff --git a/sponsors/forms.py b/sponsors/forms.py index 8d262b337..5a31605af 100644 --- a/sponsors/forms.py +++ b/sponsors/forms.py @@ -3,6 +3,7 @@ from django import forms from django.conf import settings from django.contrib.admin.widgets import AdminDateWidget +from django.core.validators import FileExtensionValidator from django.db.models import Q from django.utils import timezone from django.utils.functional import cached_property @@ -225,10 +226,11 @@ class SponsorshipApplicationForm(forms.Form): help_text="For display on our sponsor webpage. High resolution PNG or JPG, smallest dimension no less than 256px", required=False, ) - print_logo = forms.ImageField( + print_logo = forms.FileField( label="Sponsor print logo", help_text="For printed materials, signage, and projection. SVG or EPS", required=False, + validators=[FileExtensionValidator(['eps', 'epsf' 'epsi', 'svg', 'png'])], ) primary_phone = forms.CharField( @@ -557,10 +559,11 @@ class SponsorUpdateForm(forms.ModelForm): help_text="For display on our sponsor webpage. High resolution PNG or JPG, smallest dimension no less than 256px", required=False, ) - print_logo = forms.ImageField( + print_logo = forms.FileField( widget=forms.widgets.FileInput, help_text="For printed materials, signage, and projection. SVG or EPS", required=False, + validators=[FileExtensionValidator(['eps', 'epsf' 'epsi', 'svg', 'png'])], ) def __init__(self, *args, **kwargs): diff --git a/sponsors/management/commands/create_pycon_vouchers_for_sponsors.py b/sponsors/management/commands/create_pycon_vouchers_for_sponsors.py index f8b99855a..3e3b4973d 100644 --- a/sponsors/management/commands/create_pycon_vouchers_for_sponsors.py +++ b/sponsors/management/commands/create_pycon_vouchers_for_sponsors.py @@ -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_", + }, } diff --git a/sponsors/migrations/0099_auto_20231224_1854.py b/sponsors/migrations/0099_auto_20231224_1854.py new file mode 100644 index 000000000..d8aaa436c --- /dev/null +++ b/sponsors/migrations/0099_auto_20231224_1854.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.24 on 2023-12-24 18:54 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sponsors', '0098_auto_20231219_1910'), + ] + + operations = [ + migrations.AlterField( + model_name='sponsor', + name='print_logo', + field=models.FileField(blank=True, help_text='For printed materials, signage, and projection. SVG or EPS', null=True, upload_to='sponsor_print_logos', validators=[django.core.validators.FileExtensionValidator(['eps', 'epsfepsi', 'svg', 'png'])], verbose_name='Print logo'), + ), + ] diff --git a/sponsors/models/sponsors.py b/sponsors/models/sponsors.py index 9b4d8fe86..eee7f585e 100644 --- a/sponsors/models/sponsors.py +++ b/sponsors/models/sponsors.py @@ -3,6 +3,7 @@ """ from allauth.account.models import EmailAddress from django.conf import settings +from django.core.validators import FileExtensionValidator from django.db import models from django.core.exceptions import ObjectDoesNotExist from django.template.defaultfilters import slugify @@ -51,6 +52,7 @@ class Sponsor(ContentManageable): ) print_logo = models.FileField( upload_to="sponsor_print_logos", + validators=[FileExtensionValidator(['eps', 'epsf' 'epsi', 'svg', 'png'])], blank=True, null=True, verbose_name="Print logo", diff --git a/sponsors/tests/test_forms.py b/sponsors/tests/test_forms.py index 058e21625..123dc1729 100644 --- a/sponsors/tests/test_forms.py +++ b/sponsors/tests/test_forms.py @@ -1,3 +1,6 @@ +from pathlib import Path + +from django.core.files.uploadedfile import SimpleUploadedFile from model_bakery import baker from django.conf import settings @@ -438,6 +441,21 @@ def test_create_sponsor_with_valid_data_for_non_required_inputs( self.assertEqual(sponsor.landing_page_url, "https://companyx.com") self.assertEqual(sponsor.twitter_handle, "@companyx") + def test_create_sponsor_with_svg_for_print_logo( + self, + ): + tick_svg = Path(settings.STATICFILES_DIRS[0]) / "img"/"sponsors"/"tick.svg" + with tick_svg.open("rb") as fd: + uploaded_svg = SimpleUploadedFile("tick.svg", fd.read()) + self.files["print_logo"] = uploaded_svg + + form = SponsorshipApplicationForm(self.data, self.files) + self.assertTrue(form.is_valid(), form.errors) + + sponsor = form.save() + + self.assertTrue(sponsor.print_logo) + def test_use_previous_user_sponsor(self): contact = baker.make(SponsorContact, user__email="foo@foo.com") self.data = {"sponsor": contact.sponsor.id} diff --git a/templates/base.html b/templates/base.html index ffa517a91..27daceb50 100644 --- a/templates/base.html +++ b/templates/base.html @@ -86,7 +86,7 @@ + href="https://peps.python.org/peps.rss">