From b1080e5fe5d8880d7c84d1391039d269ba8244b7 Mon Sep 17 00:00:00 2001 From: Michael Price Date: Fri, 2 Mar 2018 02:37:22 -0400 Subject: [PATCH] Convert the TextAreaDiv widget to use template-based rendering as per Django's release notes: https://docs.djangoproject.com/en/2.0/releases/1.11/#template-based-widget-rendering Signed-off-by: Michael Price --- .../appearance/forms/widgets/textareadiv.html | 3 +++ mayan/apps/common/widgets.py | 10 +--------- 2 files changed, 4 insertions(+), 9 deletions(-) create mode 100644 mayan/apps/appearance/templates/appearance/forms/widgets/textareadiv.html diff --git a/mayan/apps/appearance/templates/appearance/forms/widgets/textareadiv.html b/mayan/apps/appearance/templates/appearance/forms/widgets/textareadiv.html new file mode 100644 index 0000000000..fa5afb719e --- /dev/null +++ b/mayan/apps/appearance/templates/appearance/forms/widgets/textareadiv.html @@ -0,0 +1,3 @@ +
+{% if widget.value %}{{ widget.value }}{% endif %}
+ diff --git a/mayan/apps/common/widgets.py b/mayan/apps/common/widgets.py index b9a402f7c3..fa52d50545 100644 --- a/mayan/apps/common/widgets.py +++ b/mayan/apps/common/widgets.py @@ -109,6 +109,7 @@ class TextAreaDiv(forms.widgets.Widget): Class to define a form widget that simulates the behavior of a Textarea widget but using a div tag instead """ + template_name = 'appearance/forms/widgets/textareadiv.html' def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. @@ -117,15 +118,6 @@ class TextAreaDiv(forms.widgets.Widget): default_attrs.update(attrs) super(TextAreaDiv, self).__init__(default_attrs) - def render(self, name, value, attrs=None): - if value is None: - value = '' - - flat_attrs = flatatt(self.build_attrs(attrs, name=name)) - content = conditional_escape(force_text(value)) - result = '%s' % (flat_attrs, content) - return mark_safe(result) - def two_state_template(state, ok_icon='fa fa-check', fail_icon='fa fa-times'): if state: