From 31a384f749632d4e22e47956de92294a4e502f0c Mon Sep 17 00:00:00 2001 From: blagoja Date: Thu, 11 Jul 2024 12:03:03 +0200 Subject: [PATCH] Create dataset simplified form --- ckanext/bulkupload/templates/test.html | 38 +++++++++++++++++++++ ckanext/bulkupload/views.py | 47 ++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 ckanext/bulkupload/templates/test.html diff --git a/ckanext/bulkupload/templates/test.html b/ckanext/bulkupload/templates/test.html new file mode 100644 index 0000000..9626075 --- /dev/null +++ b/ckanext/bulkupload/templates/test.html @@ -0,0 +1,38 @@ +{% extends "page.html" %} +{% import 'macros/form.html' as form %} + +{% block primary_content %} +{% block form %} +

+
+ {{ form.input('name', id='field-dataset-name', label=_('Dataset Name'), value="", error="", placeholder='eg. TransX data') }} +
{{ form.info('The name of the dataset') }}
+ {{ form.input('date-start', type='date', id='field-date-start', label=_('Date start'), value='', error='') }} +
{{ form.info('Date start') }}
+ {{ form.input('date-end', type='date', id='field-date-end', label=_('Date end'), value='', error='') }} +
{{ form.info('Date start') }}
+ +
+ +
+
+{% endblock %} +{% endblock %} + +{% block secondary_content %} + {% block info_module %} +
+

{{ _('What are datasets?') }}

+
+

+ {% trans %} + A CKAN Dataset is a collection of data resources (such as files), + together with a description and other information, at a fixed URL. + Datasets are what users see when searching for data. + {% endtrans %} +

+
+
+ {% endblock %} +{% endblock %} + diff --git a/ckanext/bulkupload/views.py b/ckanext/bulkupload/views.py index 055c6a8..d58569f 100644 --- a/ckanext/bulkupload/views.py +++ b/ckanext/bulkupload/views.py @@ -124,7 +124,54 @@ def bulk_resource_upload(pkg_name): return base.render( 'package/activity_bulk.html', extra_vars ) + +def busoperator(): + + if flask.request.method == 'GET': + context = { + "model": model, + "session": model.Session, + "user": g.user, + "auth_user_obj": g.userobj, + } + try: + tk.check_access("bulk_resource_upload", context) + except: + return tk.abort(403) + + return base.render('test.html') + + elif flask.request.method == 'POST': + context = { + "model": model, + "session": model.Session, + "user": g.user, + "auth_user_obj": g.userobj, + } + try: + tk.check_access("bulk_resource_upload", context) + except: + return tk.abort(403) + + form_data = clean_dict( + dict_fns.unflatten(tuplize_dict(parse_params(tk.request.form))) + ) + + data_dict = { + 'name': form_data['name'], + 'title': form_data['name'], + 'private': False, + } + + x = tk.get_action("package_create")(context, data_dict) + + return base.render('test.html') + + +bulkupload.add_url_rule("/dataset/busoperator", + view_func=busoperator, + methods=("GET", "POST")) bulkupload.add_url_rule("/dataset//resource/new/bulkupload", view_func=bulk_resource_upload,