From ea74e42f6be4bc89a3ad89f367a47ce0bcd2b761 Mon Sep 17 00:00:00 2001 From: amercader Date: Fri, 10 Jan 2020 15:38:51 +0100 Subject: [PATCH] [#5152] Clear the upload and url_type fields if there is a ValidationError Also add a custom error that we can use to show a warning in the template that users need to resubmit the file --- ckan/views/resource.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ckan/views/resource.py b/ckan/views/resource.py index 293c30f8a8c..d3cceafc65b 100644 --- a/ckan/views/resource.py +++ b/ckan/views/resource.py @@ -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'))