diff --git a/src/core/forms.py b/src/core/forms.py index 3d0941f5..f6e969a1 100644 --- a/src/core/forms.py +++ b/src/core/forms.py @@ -1,4 +1,5 @@ from django import forms +from django.utils.safestring import mark_safe from .models import Exhibit @@ -6,25 +7,27 @@ class UploadFileForm(forms.Form): file = forms.ImageField(required=False) + class ListTextWidget(forms.TextInput): def __init__(self, *args, **kwargs): super(ListTextWidget, self).__init__(*args, **kwargs) - self._name = 'exhibit-list' - self._list = Exhibit.objects.all().order_by('name') - self.attrs.update({'list':f'list__{self._name}'}) + self._name = "exhibit-list" + self._list = Exhibit.objects.all().order_by("name") + self.attrs.update({"list": f"list__{self._name}"}) def render(self, name, value, attrs=None, renderer=None): text_html = super(ListTextWidget, self).render(name, value, attrs=attrs) data_list = f'' for item in self._list: data_list += f'' - data_list += '' - return (text_html + data_list) + data_list += "" + return mark_safe(text_html + data_list) + class ExhibitForm(forms.Form): - exhibit = forms.CharField(required=True) + exhibit = forms.CharField(required=True) - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs): super(ExhibitForm, self).__init__(*args, **kwargs) - self.fields['exhibit'].widget = ListTextWidget() - self.fields['exhibit'].label = "" + self.fields["exhibit"].widget = ListTextWidget() + self.fields["exhibit"].label = "" diff --git a/src/core/jinja2/core/exhibit_select.jinja2 b/src/core/jinja2/core/exhibit_select.jinja2 index 22be5ce5..08c31ef7 100644 --- a/src/core/jinja2/core/exhibit_select.jinja2 +++ b/src/core/jinja2/core/exhibit_select.jinja2 @@ -16,7 +16,7 @@

{{_("Choose the Exhibition you're seeing")}}

{{ csrf_input }} - {{form}} + {{ form }}
diff --git a/src/users/views.py b/src/users/views.py index 4b31a674..45c939a3 100644 --- a/src/users/views.py +++ b/src/users/views.py @@ -1,4 +1,3 @@ -import json import logging from django.conf import settings @@ -12,7 +11,7 @@ from django.contrib.auth.views import PasswordResetView from django.contrib.messages.views import SuccessMessageMixin from django.http import Http404, JsonResponse -from django.shortcuts import get_object_or_404, redirect, render +from django.shortcuts import redirect, render from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ from django.views.decorators.cache import cache_page