Reformat using black

This commit is contained in:
cuom1999 2022-05-14 12:57:27 -05:00
parent efee4ad081
commit a87fb49918
221 changed files with 19127 additions and 7310 deletions

View file

@ -11,8 +11,17 @@ from django.utils.safestring import mark_safe
class AceWidget(forms.Textarea):
def __init__(self, mode=None, theme=None, wordwrap=False, width='100%', height='300px',
no_ace_media=False, *args, **kwargs):
def __init__(
self,
mode=None,
theme=None,
wordwrap=False,
width="100%",
height="300px",
no_ace_media=False,
*args,
**kwargs
):
self.mode = mode
self.theme = theme
self.wordwrap = wordwrap
@ -23,10 +32,10 @@ class AceWidget(forms.Textarea):
@property
def media(self):
js = [urljoin(settings.ACE_URL, 'ace.js')] if self.ace_media else []
js.append('django_ace/widget.js')
js = [urljoin(settings.ACE_URL, "ace.js")] if self.ace_media else []
js.append("django_ace/widget.js")
css = {
'screen': ['django_ace/widget.css'],
"screen": ["django_ace/widget.css"],
}
return forms.Media(js=js, css=css)
@ -34,24 +43,28 @@ class AceWidget(forms.Textarea):
attrs = attrs or {}
ace_attrs = {
'class': 'django-ace-widget loading',
'style': 'width:%s; height:%s' % (self.width, self.height),
'id': 'ace_%s' % name,
"class": "django-ace-widget loading",
"style": "width:%s; height:%s" % (self.width, self.height),
"id": "ace_%s" % name,
}
if self.mode:
ace_attrs['data-mode'] = self.mode
ace_attrs["data-mode"] = self.mode
if self.theme:
ace_attrs['data-theme'] = self.theme
ace_attrs["data-theme"] = self.theme
if self.wordwrap:
ace_attrs['data-wordwrap'] = 'true'
ace_attrs["data-wordwrap"] = "true"
attrs.update(style='width: 100%; min-width: 100%; max-width: 100%; resize: none')
attrs.update(
style="width: 100%; min-width: 100%; max-width: 100%; resize: none"
)
textarea = super(AceWidget, self).render(name, value, attrs)
html = '<div%s><div></div></div>%s' % (flatatt(ace_attrs), textarea)
html = "<div%s><div></div></div>%s" % (flatatt(ace_attrs), textarea)
# add toolbar
html = ('<div class="django-ace-editor"><div style="width: 100%%" class="django-ace-toolbar">'
'<a href="./" class="django-ace-max_min"></a></div>%s</div>') % html
html = (
'<div class="django-ace-editor"><div style="width: 100%%" class="django-ace-toolbar">'
'<a href="./" class="django-ace-max_min"></a></div>%s</div>'
) % html
return mark_safe(html)