Skip to content

Commit

Permalink
fix "C901 'FileWidget.render' is too complex (6)"
Browse files Browse the repository at this point in the history
  • Loading branch information
evgkirov committed Oct 4, 2023
1 parent bc253b9 commit 4066193
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pyuploadcare/dj/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, attrs=None):
self._client = get_uploadcare_client()
super(FileWidget, self).__init__(attrs)

def render(self, name, value, attrs=None, renderer=None):
def _widget_config(self, attrs=None):
config = {
"multiple": False,
}
Expand All @@ -81,6 +81,10 @@ def render(self, name, value, attrs=None, renderer=None):
if k not in ["class"]
}

return config

def render(self, name, value, attrs=None, renderer=None):

uploadcare_js = dj_conf.uploadcare_js
uploadcare_css = dj_conf.uploadcare_css

Expand All @@ -90,6 +94,8 @@ def render(self, name, value, attrs=None, renderer=None):
if not urlparse(uploadcare_css).netloc:
uploadcare_css = static(uploadcare_css)

config = self._widget_config(attrs=attrs)

return render_to_string(
"uploadcare/forms/widgets/file.html",
{
Expand Down

0 comments on commit 4066193

Please sign in to comment.