From 65a0b0f0cb90ac4d978853a5ca7f1a3e0609df33 Mon Sep 17 00:00:00 2001 From: oleast Date: Thu, 13 Feb 2020 20:40:56 +0100 Subject: [PATCH] Change force_text to force_str for django --- apps/approval/tests.py | 2 +- apps/dashboard/widgets.py | 32 ++++++++++++++++---------------- apps/gallery/widgets.py | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/approval/tests.py b/apps/approval/tests.py index 94751c73c7..69d4680383 100644 --- a/apps/approval/tests.py +++ b/apps/approval/tests.py @@ -155,7 +155,7 @@ def test_name_email_can_apply(self): CommitteeApplication, name="Ola Nordmann", email="test@example.org", - user=None, + applicant=None, ) self.assertEqual( diff --git a/apps/dashboard/widgets.py b/apps/dashboard/widgets.py index 5705393c93..8e4cbdebf4 100644 --- a/apps/dashboard/widgets.py +++ b/apps/dashboard/widgets.py @@ -4,7 +4,7 @@ from django.forms.utils import format_html from django.forms.widgets import TextInput -from django.utils.encoding import force_text +from django.utils.encoding import force_str DATEPICKER_WIDGET_STRING = """
\r\n @@ -105,7 +105,7 @@ def render(self, name, value, attrs=None, renderer=None): final_attrs = self.build_attrs(attrs, {"type": self.input_type, "name": name}) if value != "": final_attrs["value"] = format_html( - 'value="{}"', force_text(self.format_value(value)) + 'value="{}"', force_str(self.format_value(value)) ) else: final_attrs["value"] = "" @@ -114,13 +114,13 @@ def render(self, name, value, attrs=None, renderer=None): final_attrs["placeholder"] = "Vennligst velg en dato ..." if attrs.get("placeholder", False): # Update the placeholder text if supplied. - final_attrs["placeholder"] = force_text(attrs.get("placeholder")) + final_attrs["placeholder"] = force_str(attrs.get("placeholder")) return format_html( DATEPICKER_WIDGET_STRING, - id=force_text(final_attrs["id"]), - name=force_text(final_attrs["name"]), - placeholder=force_text(final_attrs["placeholder"]), + id=force_str(final_attrs["id"]), + name=force_str(final_attrs["name"]), + placeholder=force_str(final_attrs["placeholder"]), value=final_attrs["value"], ) @@ -149,7 +149,7 @@ def render(self, name, value, attrs=None, renderer=None): attrs = self.build_attrs(self.attrs, attrs) final_attrs = self.build_attrs(attrs, {"type": self.input_type, "name": name}) if value != "": - final_attrs["value"] = force_text(self.format_value(value)) + final_attrs["value"] = force_str(self.format_value(value)) else: final_attrs["value"] = "" @@ -157,13 +157,13 @@ def render(self, name, value, attrs=None, renderer=None): final_attrs["placeholder"] = "Vennligst velg dato og klokkeslett ..." if self.attrs.get("placeholder", False): # Update the placeholder text if supplied. - final_attrs["placeholder"] = force_text(self.attrs.get("placeholder")) + final_attrs["placeholder"] = force_str(self.attrs.get("placeholder")) return format_html( DATETIMEPICKER_WIDGET_STRING, - id=force_text(final_attrs["id"]), - name=force_text(final_attrs["name"]), - placeholder=force_text(final_attrs["placeholder"]), + id=force_str(final_attrs["id"]), + name=force_str(final_attrs["name"]), + placeholder=force_str(final_attrs["placeholder"]), value=final_attrs["value"], ) @@ -193,7 +193,7 @@ def render(self, name, value, attrs=None, renderer=None): final_attrs = self.build_attrs(attrs, {"type": self.input_type, "name": name}) if value != "": final_attrs["value"] = format_html( - 'value="{}"', force_text(self.format_value(value)) + 'value="{}"', force_str(self.format_value(value)) ) else: final_attrs["value"] = "" @@ -202,12 +202,12 @@ def render(self, name, value, attrs=None, renderer=None): final_attrs["placeholder"] = "Vennligst velg klokkeslett ..." if attrs.get("placeholder", False): # Update the placeholder text if supplied. - final_attrs["placeholder"] = force_text(attrs.get("placeholder")) + final_attrs["placeholder"] = force_str(attrs.get("placeholder")) return format_html( TIMEPICKER_WIDGET_STRING, - id=force_text(final_attrs["id"]), - name=force_text(final_attrs["name"]), - placeholder=force_text(final_attrs["placeholder"]), + id=force_str(final_attrs["id"]), + name=force_str(final_attrs["name"]), + placeholder=force_str(final_attrs["placeholder"]), value=final_attrs["value"], ) diff --git a/apps/gallery/widgets.py b/apps/gallery/widgets.py index 36a5076049..da6857b2d3 100644 --- a/apps/gallery/widgets.py +++ b/apps/gallery/widgets.py @@ -6,7 +6,7 @@ from django.forms import HiddenInput, TextInput from django.forms.utils import flatatt, format_html from django.urls import reverse_lazy -from django.utils.encoding import force_text +from django.utils.encoding import force_str from apps.gallery.models import ResponsiveImage @@ -62,7 +62,7 @@ def render(self, name, value, attrs=None, renderer=None): final_attrs = self.build_attrs(attrs, {"type": self.input_type, "name": name}) if value != "": # Only add the value attribute if the value is non-empty - final_attrs["value"] = force_text(self.format_value(value)) + final_attrs["value"] = force_str(self.format_value(value)) img = ResponsiveImage.objects.get(pk=value) img_thumb = format_html( '',