diff --git a/src/pretix/presale/forms/checkout.py b/src/pretix/presale/forms/checkout.py index b7316ceeb3..aa3173e707 100644 --- a/src/pretix/presale/forms/checkout.py +++ b/src/pretix/presale/forms/checkout.py @@ -1,13 +1,11 @@ from decimal import Decimal +from itertools import chain from django import forms from django.core.exceptions import ValidationError from django.db.models import Count, Prefetch, Q -from django.forms.widgets import RadioChoiceInput, RadioFieldRenderer from django.utils.encoding import force_text from django.utils.formats import number_format -from django.utils.html import format_html -from django.utils.safestring import mark_safe from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _ @@ -166,51 +164,35 @@ class QuestionsForm(forms.Form): self.fields['question_%s' % q.id] = field -# The following will get totally different once Django 1.11 is integrated -class AddOnVariationSelectInput(RadioChoiceInput): +class AddOnRadioSelect(forms.RadioSelect): + option_template_name = 'pretixpresale/forms/addon_choice_option.html' - def __init__(self, name, value, attrs, choice, index): - super().__init__(name, value, attrs, choice, index) - self.description = force_text(choice[2]) + def optgroups(self, name, value, attrs=None): + attrs = attrs or {} + groups = [] + has_selected = False + for index, (option_value, option_label, option_desc) in enumerate(chain(self.choices)): + if option_value is None: + option_value = '' + if isinstance(option_label, (list, tuple)): + raise TypeError('Choice groups are not supported here') + group_name = None + subgroup = [] + groups.append((group_name, subgroup, index)) - def render(self, name=None, value=None, attrs=None): - if self.id_for_label: - label_for = format_html(' for="{}"', self.id_for_label) - else: - label_for = '' - attrs = dict(self.attrs, **attrs) if attrs else self.attrs - if self.description: - return format_html( - ' ' - '