Skip to content

Commit

Permalink
[#5152] Clear the upload and url_type fields if there is a Validation…
Browse files Browse the repository at this point in the history
…Error

Also add a custom error that we can use to show a warning in the
template that users need to resubmit the file
  • Loading branch information
amercader committed Jan 10, 2020
1 parent 7c4a976 commit ea74e42
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ckan/views/resource.py
Expand Up @@ -243,6 +243,10 @@ def post(self, package_type, id):
except ValidationError as e:
errors = e.error_dict
error_summary = e.error_summary
if data.get('url_type') == 'upload' and data.get('url'):
data['url'] = ''
data['url_type'] = ''
errors['previous_upload'] = True
return self.get(package_type, id, data, errors, error_summary)
except NotAuthorized:
return base.abort(403, _(u'Unauthorized to create a resource'))
Expand Down

0 comments on commit ea74e42

Please sign in to comment.