From 63894ca3da698f08b4e27dd70b2f0dbf08b83129 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 14 Feb 2024 14:35:45 +0100 Subject: [PATCH] Update django-bootstrap3 requirement from ==23.1.* to ==23.6 (#3894) * Update django-bootstrap3 requirement from ==23.1.* to ==23.6 Removing our previous workarounds * Fix import --- pyproject.toml | 2 +- src/pretix/base/forms/renderers.py | 63 ------------------- .../django/forms/widgets/multiple_input.html | 6 -- src/pretix/control/forms/renderers.py | 3 +- src/pretix/presale/forms/renderers.py | 3 +- src/pretix/settings.py | 4 +- 6 files changed, 5 insertions(+), 76 deletions(-) delete mode 100644 src/pretix/base/forms/renderers.py delete mode 100644 src/pretix/base/templates/django/forms/widgets/multiple_input.html diff --git a/pyproject.toml b/pyproject.toml index 1523967d0..ec68ae1fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ dependencies = [ "defusedcsv>=1.1.0", "dj-static", "Django==4.2.*", - "django-bootstrap3==23.1.*", + "django-bootstrap3==23.6.*", "django-compressor==4.4", "django-countries==7.5.*", "django-filter==23.5", diff --git a/src/pretix/base/forms/renderers.py b/src/pretix/base/forms/renderers.py deleted file mode 100644 index 55f3def7b..000000000 --- a/src/pretix/base/forms/renderers.py +++ /dev/null @@ -1,63 +0,0 @@ -# -# This file is part of pretix (Community Edition). -# -# Copyright (C) 2014-2020 Raphael Michel and contributors -# Copyright (C) 2020-2021 rami.io GmbH and contributors -# -# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General -# Public License as published by the Free Software Foundation in version 3 of the License. -# -# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are -# applicable granting you additional permissions and placing additional restrictions on your usage of this software. -# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive -# this file, see . -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied -# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more -# details. -# -# You should have received a copy of the GNU Affero General Public License along with this program. If not, see -# . -# -from bootstrap3.renderers import ( - FieldRenderer as BaseFieldRenderer, - InlineFieldRenderer as BaseInlineFieldRenderer, -) -from django.forms import ( - CheckboxInput, CheckboxSelectMultiple, ClearableFileInput, RadioSelect, - SelectDateWidget, -) - - -class FieldRenderer(BaseFieldRenderer): - # Local application of https://github.com/zostera/django-bootstrap3/pull/859 - - def post_widget_render(self, html): - if isinstance(self.widget, CheckboxSelectMultiple): - html = self.list_to_class(html, "checkbox") - elif isinstance(self.widget, RadioSelect): - html = self.list_to_class(html, "radio") - elif isinstance(self.widget, SelectDateWidget): - html = self.fix_date_select_input(html) - elif isinstance(self.widget, ClearableFileInput): - html = self.fix_clearable_file_input(html) - elif isinstance(self.widget, CheckboxInput): - html = self.put_inside_label(html) - return html - - -class InlineFieldRenderer(BaseInlineFieldRenderer): - # Local application of https://github.com/zostera/django-bootstrap3/pull/859 - - def post_widget_render(self, html): - if isinstance(self.widget, CheckboxSelectMultiple): - html = self.list_to_class(html, "checkbox") - elif isinstance(self.widget, RadioSelect): - html = self.list_to_class(html, "radio") - elif isinstance(self.widget, SelectDateWidget): - html = self.fix_date_select_input(html) - elif isinstance(self.widget, ClearableFileInput): - html = self.fix_clearable_file_input(html) - elif isinstance(self.widget, CheckboxInput): - html = self.put_inside_label(html) - return html diff --git a/src/pretix/base/templates/django/forms/widgets/multiple_input.html b/src/pretix/base/templates/django/forms/widgets/multiple_input.html deleted file mode 100644 index d7c963f26..000000000 --- a/src/pretix/base/templates/django/forms/widgets/multiple_input.html +++ /dev/null @@ -1,6 +0,0 @@ -{# this is the version from django 3.x, prior to https://github.com/django/django/commit/5942ab5eb165ee2e759174e297148a40dd855920 so that django-bootstrap3 can keep doing its magic #} -{% with id=widget.attrs.id %}{% for group, options, index in widget.optgroups %}{% if group %} -
  • {{ group }}{% endif %}{% for option in options %} -
  • {% include option.template_name with widget=option %}
  • {% endfor %}{% if group %} - {% endif %}{% endfor %} -{% endwith %} \ No newline at end of file diff --git a/src/pretix/control/forms/renderers.py b/src/pretix/control/forms/renderers.py index 3a49b8bfb..485330b60 100644 --- a/src/pretix/control/forms/renderers.py +++ b/src/pretix/control/forms/renderers.py @@ -19,6 +19,7 @@ # You should have received a copy of the GNU Affero General Public License along with this program. If not, see # . # +from bootstrap3.renderers import FieldRenderer, InlineFieldRenderer from bootstrap3.text import text_value from django.forms import CheckboxInput, CheckboxSelectMultiple, RadioSelect from django.forms.utils import flatatt @@ -27,8 +28,6 @@ from django.utils.safestring import mark_safe from django.utils.translation import pgettext from i18nfield.forms import I18nFormField -from pretix.base.forms.renderers import FieldRenderer, InlineFieldRenderer - def render_label(content, label_for=None, label_class=None, label_title='', label_id='', optional=False): """ diff --git a/src/pretix/presale/forms/renderers.py b/src/pretix/presale/forms/renderers.py index 527b6ae72..a94ca72c7 100644 --- a/src/pretix/presale/forms/renderers.py +++ b/src/pretix/presale/forms/renderers.py @@ -19,6 +19,7 @@ # You should have received a copy of the GNU Affero General Public License along with this program. If not, see # . # +from bootstrap3.renderers import FieldRenderer from bootstrap3.text import text_value from bootstrap3.utils import add_css_class from django.forms import CheckboxInput, CheckboxSelectMultiple, RadioSelect @@ -27,8 +28,6 @@ from django.utils.html import escape, format_html, strip_tags from django.utils.safestring import mark_safe from django.utils.translation import pgettext -from pretix.base.forms.renderers import FieldRenderer - def render_label(content, label_for=None, label_class=None, label_title='', label_id='', optional=False, is_valid=None, attrs=None): """ diff --git a/src/pretix/settings.py b/src/pretix/settings.py index 29e14be83..5721c3c4d 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -683,8 +683,8 @@ CELERY_TASK_ROUTES = ([ BOOTSTRAP3 = { 'success_css_class': '', 'field_renderers': { - 'default': 'pretix.base.forms.renderers.FieldRenderer', - 'inline': 'pretix.base.forms.renderers.InlineFieldRenderer', + 'default': 'bootstrap3.renderers.FieldRenderer', + 'inline': 'bootstrap3.renderers.InlineFieldRenderer', 'control': 'pretix.control.forms.renderers.ControlFieldRenderer', 'control_with_visibility': 'pretix.control.forms.renderers.ControlFieldWithVisibilityRenderer', 'bulkedit': 'pretix.control.forms.renderers.BulkEditFieldRenderer',