Skip to content
Snippets Groups Projects
Commit b1067161 authored by anonymous's avatar anonymous
Browse files

ODPSH-356: fix validation

parent d005e58c
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,22 @@ ckan.module('odsh_form', function ($)
toggle(id)
$(id).change(toggle);
}
if (this.options.validateformat)
{
$('#form-submit-button').click(function ()
{
var format = $('#field-format').val()
if (format && format.length !== 0)
{
$('#resource-edit').submit();
}
else
{
$("label[for='field-format']").parent().find('.inline-error').text('Bitte geben Sie ein Format an')
}
})
}
}
};
});
\ No newline at end of file
{% resource 'odsh/odsh_image-upload.js' %}
{% resource 'odsh/odsh_form.js' %}
{% import 'macros/form.html' as form %}
{% set data = data or {} %}
......@@ -68,6 +69,7 @@
{% resource 'odsh/odsh_guessformat.js' %}
{% set format_attrs = {'data-module': 'odsh_guessformat', 'data-module-formats':h.odsh_upload_known_formats()} %}
{% set format_attrs = {} %}
{% set error_string = _('odsh_resource_format_error_label') if errors.format %}
{% call form.input('format', id='field-format', label=_('Format'), placeholder=_('eg. CSV, XML or JSON'), value=data.format, error=error_string, is_required=true, classes=['control-full'],attrs=format_attrs) %}
......@@ -100,10 +102,11 @@
{% endblock %}
{% if stage %}
{% block save_button %}
<button class="btn btn-primary btn-arrow-right" name="save" value="go-metadata" type="submit">{% block
<input type='hidden' name='save' value='go-metadata'/>
<div id='form-submit-button' data-module="odsh_form" data-module-validateformat='true' class="btn btn-primary btn-arrow-right" name="save" value="go-metadata">{% block
save_button_text
%}{{
_('Upload dataset') }}{% endblock %}</button>
_('Upload dataset') }}{% endblock %}</div>
{% endblock %}
{% else %}
{% block add_button %}
......
......@@ -29,8 +29,7 @@ class TestUpload(helpers.FunctionalTestBase):
# assert
response.mustcontain('Title: Missing value')
response.mustcontain('Description: Missing value')
response.mustcontain('odsh_spatial_uri_error_label')
response.mustcontain('odsh_temporal_start_error_label')
response.mustcontain('temporal_start: empty')
@odsh_test()
def test_upload_empty_wrong_spatial_uri(self):
......@@ -42,7 +41,7 @@ class TestUpload(helpers.FunctionalTestBase):
response = self._submit_form(form)
# assert
response.mustcontain('odsh_spatial_uri_unknown_error_label')
response.mustcontain('spatial_uri: uri unknown')
@odsh_test()
def test_upload_empty_wrong_date_temporal_start(self):
......@@ -67,19 +66,18 @@ class TestUpload(helpers.FunctionalTestBase):
response7 = self._submit_form(form)
# assert
response1.mustcontain('odsh_temporal_start_not_date_error_label')
response2.mustcontain('odsh_temporal_error_label')
response3.mustcontain('odsh_temporal_end_not_date_error_label')
response4.mustcontain('odsh_temporal_start_not_date_error_label')
response5.mustcontain('odsh_temporal_start_not_date_error_label')
response6.mustcontain('odsh_temporal_start_not_date_error_label')
response1.mustcontain('temporal_start: not a valid date')
# response2.mustcontain('odsh_temporal_error_label')
response3.mustcontain('temporal_end: not a valid date')
response4.mustcontain('temporal_start: not a valid date')
response5.mustcontain('temporal_start: not a valid date')
response6.mustcontain('temporal_start: not a valid date')
@odsh_test()
def test_upload_all_fields_set(self):
# arrange
form = self._get_package_new_form()
form['title'] = 'Titel'
form['name'] = 'sdlkjsadlfkjas'
form['notes'] = 'notes'
form['owner_org'] = self.org['id']
form[self._get_field_name(
......@@ -107,7 +105,7 @@ class TestUpload(helpers.FunctionalTestBase):
response1 = self._submit_form(form)
# assert
response1.mustcontain('odsh_licence_text_missing_error_label')
response1.mustcontain('licenseAttributionByText: empty not allowed')
def _get_field_name(self, field):
checksum = odsh_create_checksum(field)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment