django2.2: fix django server crash because of breaking change in widget rendering method

This commit is contained in:
Antoine Bartuccio 2019-10-06 14:12:15 +02:00
parent 59185ab2a8
commit cf3f5ea60c
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -56,39 +56,39 @@ from PIL import Image
class SelectSingle(Select): class SelectSingle(Select):
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None, renderer=None):
if attrs: if attrs:
attrs["class"] = "select_single" attrs["class"] = "select_single"
else: else:
attrs = {"class": "select_single"} attrs = {"class": "select_single"}
return super(SelectSingle, self).render(name, value, attrs) return super(SelectSingle, self).render(name, value, attrs, renderer)
class SelectMultiple(Select): class SelectMultiple(Select):
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None, renderer=None):
if attrs: if attrs:
attrs["class"] = "select_multiple" attrs["class"] = "select_multiple"
else: else:
attrs = {"class": "select_multiple"} attrs = {"class": "select_multiple"}
return super(SelectMultiple, self).render(name, value, attrs) return super(SelectMultiple, self).render(name, value, attrs, renderer)
class SelectDateTime(DateTimeInput): class SelectDateTime(DateTimeInput):
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None, renderer=None):
if attrs: if attrs:
attrs["class"] = "select_datetime" attrs["class"] = "select_datetime"
else: else:
attrs = {"class": "select_datetime"} attrs = {"class": "select_datetime"}
return super(SelectDateTime, self).render(name, value, attrs) return super(SelectDateTime, self).render(name, value, attrs, renderer)
class SelectDate(DateInput): class SelectDate(DateInput):
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None, renderer=None):
if attrs: if attrs:
attrs["class"] = "select_date" attrs["class"] = "select_date"
else: else:
attrs = {"class": "select_date"} attrs = {"class": "select_date"}
return super(SelectDate, self).render(name, value, attrs) return super(SelectDate, self).render(name, value, attrs, renderer)
class MarkdownInput(Textarea): class MarkdownInput(Textarea):
@ -127,7 +127,7 @@ class MarkdownInput(Textarea):
class SelectFile(TextInput): class SelectFile(TextInput):
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None, renderer=None):
if attrs: if attrs:
attrs["class"] = "select_file" attrs["class"] = "select_file"
else: else:
@ -135,7 +135,7 @@ class SelectFile(TextInput):
output = ( output = (
'%(content)s<div name="%(name)s" class="choose_file_widget" title="%(title)s"></div>' '%(content)s<div name="%(name)s" class="choose_file_widget" title="%(title)s"></div>'
% { % {
"content": super(SelectFile, self).render(name, value, attrs), "content": super(SelectFile, self).render(name, value, attrs, renderer),
"title": _("Choose file"), "title": _("Choose file"),
"name": name, "name": name,
} }
@ -151,7 +151,7 @@ class SelectFile(TextInput):
class SelectUser(TextInput): class SelectUser(TextInput):
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None, renderer=None):
if attrs: if attrs:
attrs["class"] = "select_user" attrs["class"] = "select_user"
else: else:
@ -159,7 +159,7 @@ class SelectUser(TextInput):
output = ( output = (
'%(content)s<div name="%(name)s" class="choose_user_widget" title="%(title)s"></div>' '%(content)s<div name="%(name)s" class="choose_user_widget" title="%(title)s"></div>'
% { % {
"content": super(SelectUser, self).render(name, value, attrs), "content": super(SelectUser, self).render(name, value, attrs, renderer),
"title": _("Choose user"), "title": _("Choose user"),
"name": name, "name": name,
} }