Compare commits

..

6 Commits

Author SHA1 Message Date
Raphael Michel
5094e5e4ec Bump to 3.14.2 2021-01-12 10:59:16 +01:00
Raphael Michel
222cab115e Fix UX quirk in phone number field triggered by American numbers 2021-01-12 10:58:57 +01:00
Raphael Michel
7809f8ac1a API: Fix CSS generation after change in event settings 2021-01-12 10:58:46 +01:00
Raphael Michel
839c76769c Fix duplicate listing of fonts in event settings 2021-01-12 10:58:16 +01:00
Raphael Michel
8b4cf9db70 Fix tests failing in 2021 2021-01-12 10:58:16 +01:00
Raphael Michel
099ab079f9 Fix geocoding with opencage 2021-01-12 10:58:16 +01:00
6 changed files with 43 additions and 18 deletions

View File

@@ -1 +1 @@
__version__ = "3.14.1"
__version__ = "3.14.2"

View File

@@ -392,6 +392,6 @@ class EventSettingsView(views.APIView):
}
)
if any(p in s.changed_data for p in SETTINGS_AFFECTING_CSS):
regenerate_css.apply_async(args=(request.organizer.pk,))
regenerate_css.apply_async(args=(request.event.pk,))
s = EventSettingsSerializer(instance=request.event.settings, event=request.event)
return Response(s.data)

View File

@@ -9,12 +9,14 @@ import pycountry
import pytz
import vat_moss.errors
import vat_moss.id
from babel import Locale
from django import forms
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db.models import QuerySet
from django.forms import Select
from django.utils import translation
from django.utils.formats import date_format
from django.utils.html import escape
from django.utils.safestring import mark_safe
@@ -24,9 +26,7 @@ from django_countries import countries
from django_countries.fields import Country, CountryField
from phonenumber_field.formfields import PhoneNumberField
from phonenumber_field.phonenumber import PhoneNumber
from phonenumber_field.widgets import (
PhoneNumberPrefixWidget, PhonePrefixSelect,
)
from phonenumber_field.widgets import PhoneNumberPrefixWidget
from phonenumbers import NumberParseException, national_significant_number
from phonenumbers.data import _COUNTRY_CODE_TO_REGION_CODE
@@ -205,10 +205,39 @@ class NamePartsFormField(forms.MultiValueField):
return value
class WrappedPhonePrefixSelect(PhonePrefixSelect):
def __init__(self, *args, **kwargs):
with language(get_babel_locale()):
super().__init__(*args, **kwargs)
class WrappedPhonePrefixSelect(Select):
initial = None
def __init__(self, initial=None):
choices = [("", "---------")]
language = get_babel_locale() # changed from default implementation that used the django locale
locale = Locale(translation.to_locale(language))
for prefix, values in _COUNTRY_CODE_TO_REGION_CODE.items():
prefix = "+%d" % prefix
if initial and initial in values:
self.initial = prefix
for country_code in values:
country_name = locale.territories.get(country_code)
if country_name:
choices.append((prefix, "{} {}".format(country_name, prefix)))
super().__init__(choices=sorted(choices, key=lambda item: item[1]))
def render(self, name, value, *args, **kwargs):
return super().render(name, value or self.initial, *args, **kwargs)
def get_context(self, name, value, attrs):
if value and self.choices[1][0] != value:
matching_choices = len([1 for p, c in self.choices if p == value])
if matching_choices > 1:
# Some countries share a phone pretix, for example +1 is used all over the Americas.
# This causes a UX problem: If the default value or the existing data is +12125552368,
# the widget will just show the first <option> entry with value="+1" as selected,
# which alphabetically is America Samoa, although most numbers statistically are from
# the US. As a workaround, we detect this case and add an aditional choice value with
# just <option value="+1">+1</option> without an explicit country.
self.choices.insert(1, (value, value))
context = super().get_context(name, value, attrs)
return context
class WrappedPhoneNumberPrefixWidget(PhoneNumberPrefixWidget):

View File

@@ -35,7 +35,6 @@ from pretix.helpers.countries import CachedCountries
from pretix.multidomain.models import KnownDomain
from pretix.multidomain.urlreverse import build_absolute_uri
from pretix.plugins.banktransfer.payment import BankTransfer
from pretix.presale.style import get_fonts
class EventWizardFoundationForm(forms.Form):
@@ -549,9 +548,6 @@ class EventSettingsForm(SettingsForm):
if not self.event.has_subevents:
del self.fields['frontpage_subevent_ordering']
del self.fields['event_list_type']
self.fields['primary_font'].choices += [
(a, {"title": a, "data": v}) for a, v in get_fonts().items()
]
# create "virtual" fields for better UX when editing <name>_asked and <name>_required fields
self.virtual_keys = []

View File

@@ -25,7 +25,7 @@ class GeoCodeView(LoginRequiredMixin, View):
gs = GlobalSettingsObject()
if gs.settings.opencagedata_apikey:
res = self._use_opencage(q)
if gs.settings.mapquest_apikey:
elif gs.settings.mapquest_apikey:
res = self._use_mapquest(q)
else:
return JsonResponse({

View File

@@ -142,7 +142,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
data = json.loads(response.content.decode())
assert data == {
"name": "30C3",
"date_range": "Dec. 26, 2021 00:00",
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
"currency": "EUR",
"show_variations_expanded": False,
"display_net_prices": False,
@@ -276,7 +276,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
data = json.loads(response.content.decode())
assert data == {
"name": "30C3",
"date_range": "Dec. 26, 2021 00:00",
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
"currency": "EUR",
"show_variations_expanded": False,
"display_net_prices": False,
@@ -327,7 +327,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
data = json.loads(response.content.decode())
assert data == {
"name": "30C3",
"date_range": "Dec. 26, 2021 00:00",
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
"currency": "EUR",
"show_variations_expanded": False,
"display_net_prices": False,
@@ -394,7 +394,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
data = json.loads(response.content.decode())
assert data == {
"name": "30C3",
"date_range": "Dec. 26, 2021 00:00",
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
"currency": "EUR",
'poweredby': '<a href="https://pretix.eu" target="_blank" rel="noopener">event ticketing powered by pretix</a>',
"show_variations_expanded": False,