Widgets' .render() method now must accept an additional keyword argument (renderer); adjusted the code accordingly (including a library patch -- pull request also submitted).

- Legacy-Id: 18056
This commit is contained in:
Henrik Levkowetz 2020-06-24 20:44:47 +00:00
parent a9348f129a
commit 27da6e86d4
2 changed files with 38 additions and 2 deletions

View file

@ -17,7 +17,7 @@ class ButtonWidget(Widget):
self.required_label = kwargs.pop('required_label', None) self.required_label = kwargs.pop('required_label', None)
super(ButtonWidget, self).__init__(*args, **kwargs) super(ButtonWidget, self).__init__(*args, **kwargs)
def render(self, name, value, attrs=None): def render(self, name, value, **kwargs):
html = '<span style="display: none" class="showAttachsOn">%s</span>' % conditional_escape(self.show_on) html = '<span style="display: none" class="showAttachsOn">%s</span>' % conditional_escape(self.show_on)
html += '<span style="display: none" class="attachEnabledLabel">%s</span>' % conditional_escape(self.label) html += '<span style="display: none" class="attachEnabledLabel">%s</span>' % conditional_escape(self.label)
if self.require: if self.require:
@ -30,7 +30,7 @@ class ButtonWidget(Widget):
class ShowAttachmentsWidget(Widget): class ShowAttachmentsWidget(Widget):
def render(self, name, value, attrs=None): def render(self, name, value, **kwargs):
html = '<div id="id_%s">' % name html = '<div id="id_%s">' % name
html += '<span style="display: none" class="showAttachmentsEmpty form-control widget">No files attached</span>' html += '<span style="display: none" class="showAttachmentsEmpty form-control widget">No files attached</span>'
html += '<div class="attachedFiles form-control widget">' html += '<div class="attachedFiles form-control widget">'

View file

@ -0,0 +1,36 @@
--- django_password_strength/widgets.py.orig 2020-06-24 16:07:28.479533134 +0200
+++ django_password_strength/widgets.py 2020-06-24 16:08:09.540714290 +0200
@@ -8,7 +8,7 @@
Form widget to show the user how strong his/her password is.
"""
- def render(self, name, value, attrs=None):
+ def render(self, name, value, **kwargs):
strength_markup = """
<div style="margin-top: 10px;">
<div class="progress" style="margin-bottom: 10px;">
@@ -30,7 +30,7 @@
except KeyError:
self.attrs['class'] = 'password_strength'
- return mark_safe( super(PasswordInput, self).render(name, value, attrs) + strength_markup )
+ return mark_safe( super(PasswordInput, self).render(name, value, **kwargs) + strength_markup )
class Media:
js = (
@@ -48,7 +48,7 @@
super(PasswordConfirmationInput, self).__init__(attrs, render_value)
self.confirm_with=confirm_with
- def render(self, name, value, attrs=None):
+ def render(self, name, value, **kwargs):
if self.confirm_with:
self.attrs['data-confirm-with'] = 'id_%s' % self.confirm_with
@@ -68,4 +68,4 @@
except KeyError:
self.attrs['class'] = 'password_confirmation'
- return mark_safe( super(PasswordInput, self).render(name, value, attrs) + confirmation_markup )
+ return mark_safe( super(PasswordInput, self).render(name, value, **kwargs) + confirmation_markup )