Skip to content

Commit

Permalink
Prepare the dataset name from title
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Jul 11, 2024
1 parent 31a384f commit 3fd21c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ckanext/bulkupload/templates/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% 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') }}
{{ form.input('title', id='field-dataset-title', label=_('Dataset Title'), 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>
Expand Down
8 changes: 5 additions & 3 deletions ckanext/bulkupload/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ def busoperator():
form_data = clean_dict(
dict_fns.unflatten(tuplize_dict(parse_params(tk.request.form)))
)

name_validated = form_data['title'].replace(' ', '-').lower()

data_dict = {
'name': form_data['name'],
'title': form_data['name'],
'name': name_validated,
'title': form_data['title'],
'private': False,
'status': 'active',
}

x = tk.get_action("package_create")(context, data_dict)
Expand Down

0 comments on commit 3fd21c1

Please sign in to comment.