Skip to content

Commit

Permalink
Convert rendered string into SafeString
Browse files Browse the repository at this point in the history
b/c the ability to return a str, rather than a SafeString has been
removed which breaks SimpleMDE rendering b/c the text gets escaped and
not rendered by the browser.

See: https://docs.djangoproject.com/en/5.0/releases/5.0/
  • Loading branch information
atodorov committed Jun 17, 2024
1 parent 956d253 commit 5c0096c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tcms/core/widgets.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright (c) 2018,2021 Kiwi TCMS project. All rights reserved.
# Copyright (c) 2018-2024 Kiwi TCMS project. All rights reserved.
# Author: Alexander Todorov <[email protected]>

"""
Custom widgets for Django
"""
from django import forms
from django.utils.dateparse import parse_duration
from django.utils.safestring import SafeString


class SimpleMDE(forms.Textarea):
Expand All @@ -24,9 +25,11 @@ def render(self, name, value, attrs=None, renderer=None):
}
)
rendered_string = super().render(name, value, attrs, renderer)
rendered_string += f"""
rendered_string += SafeString(
f"""
<input id="{self.file_upload_id}" type="file" style="display: none">
"""
)
return rendered_string

class Media:
Expand Down

0 comments on commit 5c0096c

Please sign in to comment.