From e361d5f0f51e0541d09b0d6a654463cf214ebc5d Mon Sep 17 00:00:00 2001 From: Gustavo Andres Morero Date: Tue, 11 Apr 2017 15:27:13 -0300 Subject: [PATCH] widgets and forms updates for django 1.11. --- wiki/editors/markitup.py | 18 +++--------------- wiki/forms.py | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/wiki/editors/markitup.py b/wiki/editors/markitup.py index 54332ff4..1a8d2fa1 100644 --- a/wiki/editors/markitup.py +++ b/wiki/editors/markitup.py @@ -20,8 +20,6 @@ except ImportError: return(x) - - class MarkItUpAdminWidget(forms.Widget): """A simplified more fail-safe widget for the backend""" @@ -34,10 +32,10 @@ class MarkItUpAdminWidget(forms.Widget): default_attrs.update(attrs) super(MarkItUpAdminWidget, self).__init__(default_attrs) - def render(self, name, value, attrs=None): + def render(self, name, value, attrs=None, renderer=None): if value is None: value = '' - final_attrs = self.build_attrs(attrs, name=name) + final_attrs = self.build_attrs(attrs, extra_attrs={'name': name}) return mark_safe( '%s' % (flatatt(final_attrs), @@ -45,7 +43,7 @@ class MarkItUpAdminWidget(forms.Widget): force_unicode(value)))) -class MarkItUpWidget(forms.Widget): +class MarkItUpWidget(forms.Textarea): def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. @@ -55,16 +53,6 @@ class MarkItUpWidget(forms.Widget): default_attrs.update(attrs) super(MarkItUpWidget, self).__init__(default_attrs) - def render(self, name, value, attrs=None): - if value is None: - value = '' - final_attrs = self.build_attrs(attrs, name=name) - return mark_safe( - '
%s
' % - (flatatt(final_attrs), - conditional_escape( - force_unicode(value)))) - class MarkItUp(BaseEditor): editor_id = 'markitup' diff --git a/wiki/forms.py b/wiki/forms.py index 5e73ff4e..8de3eef8 100644 --- a/wiki/forms.py +++ b/wiki/forms.py @@ -264,7 +264,7 @@ class SelectWidgetBootstrap(forms.Select): def render(self, name, value, attrs=None, choices=()): if value is None: value = '' - final_attrs = self.build_attrs(attrs, name=name) + final_attrs = self.build_attrs(attrs, extra_attrs={'name': name}) output = [ """""" """ """ -- 2.45.2