From d0bac137259083940c2cec9eb73fe3ebb9cd2c82 Mon Sep 17 00:00:00 2001 From: Filip Mitrovski Date: Tue, 13 Aug 2024 15:13:55 +0200 Subject: [PATCH] VIXTE-25 error message displayed when no file is attached on Quick TXC --- .../bulkupload/templates/package/resource_busoperator.html | 3 +++ ckanext/bulkupload/views.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/ckanext/bulkupload/templates/package/resource_busoperator.html b/ckanext/bulkupload/templates/package/resource_busoperator.html index d04f704..24399ed 100644 --- a/ckanext/bulkupload/templates/package/resource_busoperator.html +++ b/ckanext/bulkupload/templates/package/resource_busoperator.html @@ -4,6 +4,9 @@ {% block primary_content %}

{% block form %} + {% if errors %} +

Please choose a file

+{% endif %}
{{ form.input('title', id='field-dataset-title', label=_('Dataset Title'), value=pkg_dict.title, error="", placeholder='eg. TransX data') }}
{{ form.info('The name of the dataset') }}
diff --git a/ckanext/bulkupload/views.py b/ckanext/bulkupload/views.py index 7ae3beb..dfa19b0 100644 --- a/ckanext/bulkupload/views.py +++ b/ckanext/bulkupload/views.py @@ -160,6 +160,12 @@ def bulk_resource_upload(pkg_name): pkg_dict = get.package_show(context, pkg_name_dict) uploaded_files = flask.request.files.getlist("file[]") + if not uploaded_files or not any(f for f in uploaded_files): + errors = 'Please choose a file' + extra_var = {'errors': errors, + 'pkg_dict': pkg_dict} + return base.render('package/resource_busoperator.html', extra_var) + # For newly created datasets if pkg_dict['state'] != 'active': patch_package_data = {