Skip to content

Commit

Permalink
Create dataset simplified form
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Jul 11, 2024
1 parent 3044b87 commit 31a384f
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
38 changes: 38 additions & 0 deletions ckanext/bulkupload/templates/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends "page.html" %}
{% import 'macros/form.html' as form %}

{% block primary_content %}
{% block form %}
<p> </p>
<form id="bulk_upload_form" method="post" enctype="multipart/form-data">
{{ form.input('name', id='field-dataset-name', label=_('Dataset Name'), value="", error="", placeholder='eg. TransX data') }}
<div style="margin:-20px 0px 20px 0px;"><small>{{ form.info('The name of the dataset') }}</small></div>
{{ form.input('date-start', type='date', id='field-date-start', label=_('Date start'), value='', error='') }}
<div style="margin:-20px 0px 20px 0px;"><small>{{ form.info('Date start') }}</small></div>
{{ form.input('date-end', type='date', id='field-date-end', label=_('Date end'), value='', error='') }}
<div style="margin:-20px 0px 20px 0px;"><small>{{ form.info('Date start') }}</small></div>

<div style="display:flex; gap:10px">
<button type='submit', class ='btn btn-primary', icon='plus-square'>{{_('Create Dataset')}}</button>
</div>
</form>
{% endblock %}
{% endblock %}

{% block secondary_content %}
{% block info_module %}
<section class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="fa fa-info-circle"></i> {{ _('What are datasets?') }}</h2>
<div class="module-content">
<p>
{% 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 %}
</p>
</div>
</section>
{% endblock %}
{% endblock %}

47 changes: 47 additions & 0 deletions ckanext/bulkupload/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<pkg_name>/resource/new/bulkupload",
view_func=bulk_resource_upload,
Expand Down

0 comments on commit 31a384f

Please sign in to comment.