mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Upgrade to Django 3.0 and other dependencies (#1568)
* Upgrade Django to 3.0 and other dependencies to recent versions * Fix otp version contsraint * Remove six dependency * Resolve some warnings * Fix failing tests * Update django-countries * Resolve all RemovedInDjango31Warnings in test suite * Run isort * Fix import * Update PostgreSQL version on travis
This commit is contained in:
@@ -10,7 +10,7 @@ from django.shortcuts import redirect
|
||||
from django.utils import translation
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import (
|
||||
get_language, pgettext_lazy, ugettext_lazy as _,
|
||||
get_language, gettext_lazy as _, pgettext_lazy,
|
||||
)
|
||||
from django.views.generic.base import TemplateResponseMixin
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
@@ -3,11 +3,11 @@ from itertools import chain
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db.models import Count, Prefetch
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.formats import number_format
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from pretix.base.forms.questions import (
|
||||
BaseInvoiceAddressForm, BaseQuestionsForm,
|
||||
@@ -105,7 +105,7 @@ class AddOnRadioSelect(forms.RadioSelect):
|
||||
groups.append((group_name, subgroup, index))
|
||||
|
||||
selected = (
|
||||
force_text(option_value) in value and
|
||||
force_str(option_value) in value and
|
||||
(has_selected is False or self.allow_multiple_selected)
|
||||
)
|
||||
if selected is True and has_selected is False:
|
||||
@@ -121,9 +121,9 @@ class AddOnRadioSelect(forms.RadioSelect):
|
||||
|
||||
class AddOnVariationField(forms.ChoiceField):
|
||||
def valid_value(self, value):
|
||||
text_value = force_text(value)
|
||||
text_value = force_str(value)
|
||||
for k, v, d in self.choices:
|
||||
if value == k or text_value == force_text(k):
|
||||
if value == k or text_value == force_str(k):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class ResendLinkForm(forms.Form):
|
||||
|
||||
@@ -5,7 +5,7 @@ import pytz
|
||||
import vobject
|
||||
from django.conf import settings
|
||||
from django.utils.formats import date_format
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from pretix.base.models import Event
|
||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.http import Http404
|
||||
from django.shortcuts import redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.urls import resolve
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_scopes import scope
|
||||
|
||||
from pretix.base.channels import WebshopSalesChannel
|
||||
|
||||
@@ -6,7 +6,6 @@ from itertools import groupby
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models import Prefetch, Sum
|
||||
from django.utils.decorators import available_attrs
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django_scopes import scopes_disabled
|
||||
@@ -282,7 +281,7 @@ def allow_frame_if_namespaced(view_func):
|
||||
if request.resolver_match and request.resolver_match.kwargs.get('cart_namespace'):
|
||||
resp.xframe_options_exempt = True
|
||||
return resp
|
||||
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
|
||||
return wraps(view_func)(wrapped_view)
|
||||
|
||||
|
||||
def allow_cors_if_namespaced(view_func):
|
||||
@@ -295,7 +294,7 @@ def allow_cors_if_namespaced(view_func):
|
||||
if request.resolver_match and request.resolver_match.kwargs.get('cart_namespace'):
|
||||
resp['Access-Control-Allow-Origin'] = '*'
|
||||
return resp
|
||||
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
|
||||
return wraps(view_func)(wrapped_view)
|
||||
|
||||
|
||||
def iframe_entry_view_wrapper(view_func):
|
||||
@@ -321,4 +320,4 @@ def iframe_entry_view_wrapper(view_func):
|
||||
|
||||
resp = view_func(request, *args, **kwargs)
|
||||
return resp
|
||||
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
|
||||
return wraps(view_func)(wrapped_view)
|
||||
|
||||
@@ -14,7 +14,7 @@ from django.utils.decorators import method_decorator
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.http import is_safe_url
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from django.views.generic import TemplateView, View
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.contrib import messages
|
||||
from django.http import Http404
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import View
|
||||
|
||||
from pretix.base.services.cart import CartError
|
||||
|
||||
@@ -12,7 +12,7 @@ from django.http import Http404, HttpResponse
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import pgettext_lazy, ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
from django.views import View
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
@@ -2,7 +2,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.http import is_safe_url
|
||||
from django.utils.http import url_has_allowed_host_and_scheme
|
||||
from django.views.generic import View
|
||||
|
||||
from pretix.helpers.cookies import set_cookie_without_samesite
|
||||
@@ -14,7 +14,7 @@ class LocaleSet(NoSearchIndexViewMixin, View):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
url = request.GET.get('next', request.headers.get('Referer', '/'))
|
||||
url = url if is_safe_url(url, allowed_hosts=[request.get_host()]) else '/'
|
||||
url = url if url_has_allowed_host_and_scheme(url, allowed_hosts=[request.get_host()]) else '/'
|
||||
resp = HttpResponseRedirect(url)
|
||||
|
||||
locale = request.GET.get('locale')
|
||||
|
||||
@@ -15,7 +15,7 @@ from django.shortcuts import get_object_or_404, redirect
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from django.views.generic import TemplateView, View
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views import View
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils import translation
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import pgettext_lazy, ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
from django.views.generic import FormView
|
||||
|
||||
from pretix.base.models.event import SubEvent
|
||||
|
||||
@@ -18,7 +18,7 @@ from django.template import Context, Engine
|
||||
from django.template.loader import get_template
|
||||
from django.utils.formats import date_format
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import get_language, pgettext, ugettext
|
||||
from django.utils.translation import get_language, gettext, pgettext
|
||||
from django.utils.translation.trans_real import DjangoTranslation
|
||||
from django.views import View
|
||||
from django.views.decorators.cache import cache_page
|
||||
@@ -27,7 +27,7 @@ from django.views.decorators.http import condition
|
||||
from django.views.i18n import (
|
||||
JavaScriptCatalog, get_formats, js_catalog_template,
|
||||
)
|
||||
from lxml import etree
|
||||
from lxml import html
|
||||
|
||||
from pretix.base.i18n import language
|
||||
from pretix.base.models import CartPosition, Event, Quota, SubEvent, Voucher
|
||||
@@ -74,7 +74,7 @@ def widget_css(request, **kwargs):
|
||||
return resp
|
||||
else:
|
||||
tpl = get_template('pretixpresale/widget_dummy.html')
|
||||
et = etree.fromstring(tpl.render({})).attrib['href'].replace(settings.STATIC_URL, '')
|
||||
et = html.fromstring(tpl.render({})).xpath('/html/head/link')[0].attrib['href'].replace(settings.STATIC_URL, '')
|
||||
f = finders.find(et)
|
||||
resp = FileResponse(open(f, 'rb'), content_type='text/css')
|
||||
return resp
|
||||
@@ -274,7 +274,7 @@ class WidgetAPIProductList(EventListMixin, View):
|
||||
|
||||
if not request.event.live:
|
||||
return self.response({
|
||||
'error': ugettext('This ticket shop is currently disabled.')
|
||||
'error': gettext('This ticket shop is currently disabled.')
|
||||
})
|
||||
|
||||
self.subevent = None
|
||||
@@ -283,14 +283,14 @@ class WidgetAPIProductList(EventListMixin, View):
|
||||
self.subevent = request.event.subevents.filter(pk=kwargs['subevent'], active=True).first()
|
||||
if not self.subevent:
|
||||
return self.response({
|
||||
'error': ugettext('The selected date does not exist in this event series.')
|
||||
'error': gettext('The selected date does not exist in this event series.')
|
||||
})
|
||||
else:
|
||||
return self._get_event_list(request, **kwargs)
|
||||
else:
|
||||
if 'subevent' in kwargs:
|
||||
return self.response({
|
||||
'error': ugettext('This is not an event series.')
|
||||
'error': gettext('This is not an event series.')
|
||||
})
|
||||
return self._get_event_view(request, **kwargs)
|
||||
|
||||
@@ -306,28 +306,28 @@ class WidgetAPIProductList(EventListMixin, View):
|
||||
if ev.presale_is_running and event.settings.event_list_availability and ev.best_availability_state is not None:
|
||||
if ev.best_availability_state == Quota.AVAILABILITY_OK:
|
||||
availability['color'] = 'green'
|
||||
availability['text'] = ugettext('Book now')
|
||||
availability['text'] = gettext('Book now')
|
||||
elif event.settings.waiting_list_enabled and ev.best_availability_state >= 0:
|
||||
availability['color'] = 'orange'
|
||||
availability['text'] = ugettext('Waiting list')
|
||||
availability['text'] = gettext('Waiting list')
|
||||
elif ev.best_availability_state == Quota.AVAILABILITY_RESERVED:
|
||||
availability['color'] = 'orange'
|
||||
availability['text'] = ugettext('Reserved')
|
||||
availability['text'] = gettext('Reserved')
|
||||
elif ev.best_availability_state < Quota.AVAILABILITY_RESERVED:
|
||||
availability['color'] = 'red'
|
||||
availability['text'] = ugettext('Sold out')
|
||||
availability['text'] = gettext('Sold out')
|
||||
elif ev.presale_is_running:
|
||||
availability['color'] = 'green'
|
||||
availability['text'] = ugettext('Book now')
|
||||
availability['text'] = gettext('Book now')
|
||||
elif ev.presale_has_ended:
|
||||
availability['color'] = 'red'
|
||||
availability['text'] = ugettext('Sale over')
|
||||
availability['text'] = gettext('Sale over')
|
||||
elif event.settings.presale_start_show_date and ev.presale_start:
|
||||
availability['color'] = 'orange'
|
||||
availability['text'] = ugettext('from %(start_date)s') % {'start_date': date_format(ev.presale_start, "SHORT_DATE_FORMAT")}
|
||||
availability['text'] = gettext('from %(start_date)s') % {'start_date': date_format(ev.presale_start, "SHORT_DATE_FORMAT")}
|
||||
else:
|
||||
availability['color'] = 'orange'
|
||||
availability['text'] = ugettext('Sale soon')
|
||||
availability['text'] = gettext('Sale soon')
|
||||
return availability
|
||||
|
||||
def _serialize_events(self, ebd):
|
||||
@@ -442,7 +442,7 @@ class WidgetAPIProductList(EventListMixin, View):
|
||||
event.min_from.astimezone(tz),
|
||||
(event.max_fromto or event.max_to or event.max_from).astimezone(tz)
|
||||
)
|
||||
avail = {'color': 'none', 'text': ugettext('Event series')}
|
||||
avail = {'color': 'none', 'text': gettext('Event series')}
|
||||
else:
|
||||
dr = event.get_date_range_display(tz) + (
|
||||
" " + event.get_time_from_display(tz) if event.settings.show_times else ""
|
||||
@@ -498,14 +498,14 @@ class WidgetAPIProductList(EventListMixin, View):
|
||||
if request.event.settings.presale_has_ended_text:
|
||||
data['error'] = str(request.event.settings.presale_has_ended_text)
|
||||
else:
|
||||
data['error'] = ugettext('The presale period for this event is over.')
|
||||
data['error'] = gettext('The presale period for this event is over.')
|
||||
elif request.event.settings.presale_start_show_date:
|
||||
data['error'] = ugettext('The presale for this event will start on %(date)s at %(time)s.') % {
|
||||
data['error'] = gettext('The presale for this event will start on %(date)s at %(time)s.') % {
|
||||
'date': date_format(ev.presale_start.astimezone(request.event.timezone), "SHORT_DATE_FORMAT"),
|
||||
'time': date_format(ev.presale_start.astimezone(request.event.timezone), "TIME_FORMAT"),
|
||||
}
|
||||
else:
|
||||
data['error'] = ugettext('The presale for this event has not yet started.')
|
||||
data['error'] = gettext('The presale for this event has not yet started.')
|
||||
|
||||
self.voucher = None
|
||||
if 'voucher' in request.GET:
|
||||
|
||||
Reference in New Issue
Block a user