Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace force_text with force_str to avoid ImportError #986

Merged
merged 2 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Developers
* Lucas Stone-Drake - https://github.com/LucasSD
* absolutely-not-bot - https://github.com/absolutely-not-bot
* Jaspreet Dhillon - https://github.com/jaspreetsd902
* Sofiko Alaverdashvili - https://github.com/sophiamartelli

Translators
-----------
Expand Down
8 changes: 4 additions & 4 deletions wger/utils/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
SelectMultiple,
TextInput,
)
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import (
conditional_escape,
escape,
Expand Down Expand Up @@ -129,14 +129,14 @@ def render(self, name, value, attrs=None, choices=(), renderer=None):

def render_options(self, choices, selected_choices):
# Normalize to strings.
selected_choices = set(force_text(v) for v in selected_choices)
selected_choices = set(force_str(v) for v in selected_choices)
output = []
for option_value, option_label in chain(self.choices, choices):
output.append(self.render_option(selected_choices, option_value, option_label))
return '\n'.join(output)

def render_option(self, selected_choices, option_value, option_label):
option_value = force_text(option_value)
option_value = force_str(option_value)
if option_value in selected_choices:

return """
Expand All @@ -150,7 +150,7 @@ def render_option(self, selected_choices, option_value, option_label):
<input type="hidden" name="exercises" value="%(id)s">
</div>
""" % {
'value': conditional_escape(force_text(option_label)),
'value': conditional_escape(force_str(option_label)),
'id': escape(option_value),
'div_id': uuid.uuid4()
}
Expand Down