Skip to content

Commit 13600fa

Browse files
author
simeonwetzel
committed
fix: after migration latest ckan version csrf field needed to be added to the dataset edit form. Validators had to be fixed.
1 parent 237c10b commit 13600fa

11 files changed

Lines changed: 87 additions & 52 deletions

File tree

ckanext/scheming/assets/js/spatial_form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
data-module="spatial-form"
2222
data-input_id="{{ id }}"
2323
data-extent="{{ value }}"
24-
data-module-site_url="{{ h.dump_json(h.url('/', locale='default', qualified=true)) }}"
24+
data-module-site_url="{{ h.dump_json(h.url_for('/', locale='default', qualified=true)) }}"
2525
data-module-map_config="{{ h.dump_json(map_config) }}">
2626
<div id="dataset-map-container"></div>
2727
</div>

ckanext/scheming/dataset_klimakonform_applications.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"label": "Application Type",
6565
"help_text": "Select at least one application type",
6666
"preset": "multiple_checkbox",
67-
"required": "true",
67+
"required": true,
6868
"choices": [
6969
{
7070
"value": "Visualization Service",
@@ -107,7 +107,7 @@
107107
{
108108
"field_name": "name",
109109
"label": "Name",
110-
"validators": "if_empty_same_as(url) unicode",
110+
"validators": "if_empty_same_as(url)",
111111
"form_placeholder": "leave blank to use resource file name"
112112
},
113113
{

ckanext/scheming/dataset_klimakonform_live.json

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"label": "Theme / Category",
6565
"help_text": "Select at least one INSPIRE theme. Further information at: http://inspire.ec.europa.eu/theme",
6666
"preset": "multiple_checkbox",
67-
"required": "true",
67+
"required": true,
6868
"choices": [
6969
{
7070
"value": "http://inspire.ec.europa.eu/theme/ad",
@@ -242,6 +242,11 @@
242242
"label": "Temporal Coverage End",
243243
"preset": "date_range_end"
244244
},
245+
{
246+
"field_name": "temporal_coverage",
247+
"label": "Temporal Coverage Total",
248+
"preset": "date_range_total"
249+
},
245250
{
246251
"field_name": "temporal_resolution",
247252
"label": "Temporal Resolution",
@@ -274,43 +279,9 @@
274279
{
275280
"field_name": "product_type",
276281
"label": "Datensatztyp",
277-
"help_text": "Select a dataset type",
278-
"preset": "multiple_checkbox",
279-
"required": "true",
280-
"choices": [
281-
{
282-
"value": "Klimaprojektion",
283-
"label": "Klimaprojektion"
284-
},
285-
{
286-
"value": "Beobachtungsdaten",
287-
"label": "Beobachtungsdaten"
288-
},
289-
{
290-
"value": "Hydrologische Daten",
291-
"label": "Hydrologische Daten"
292-
},
293-
{
294-
"value": "Geologische Daten",
295-
"label": "Geologische Daten"
296-
},
297-
{
298-
"value": "Geobasisdaten",
299-
"label": "Geobasisdaten"
300-
},
301-
{
302-
"value": "Landnutzungsdaten",
303-
"label": "Landnutzungsdaten"
304-
},
305-
{
306-
"value": "Oberflächen- /Geländemodelle",
307-
"label": "Oberflächen- /Geländemodelle"
308-
},
309-
{
310-
"value": "Geobasisdaten",
311-
"label": "Geobasisdaten"
312-
}
313-
]
282+
"required_if_value_in": "spatial_resolution",
283+
"preset": "product_type",
284+
"help_text": "Select a dataset type"
314285
},
315286
{
316287
"field_name": "license_id",
@@ -329,7 +300,7 @@
329300
{
330301
"field_name": "name",
331302
"label": "Name",
332-
"validators": "if_empty_same_as(url) unicode",
303+
"validators": "if_empty_same_as(url)",
333304
"form_placeholder": "leave blank to use resource file name"
334305
},
335306
{

ckanext/scheming/dataset_overview.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
{
123123
"field_name": "name",
124124
"label": "CKAN Default: Name",
125-
"validators": "if_empty_same_as(url) unicode"
125+
"validators": "if_empty_same_as(url)"
126126
},
127127
{
128128
"field_name": "description",
@@ -132,7 +132,7 @@
132132
{
133133
"field_name": "format",
134134
"label": "CKAN Default: Format",
135-
"validators": "if_empty_guess_format ignore_missing clean_format unicode",
135+
"validators": "if_empty_guess_format ignore_missing clean_format",
136136
"form_snippet": "fixed_autocomplete.html",
137137
"form_placeholder": "eg. CSV, XML or JSON",
138138
"form_attrs": {

ckanext/scheming/plugins.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ class SchemingDatasetsPlugin(p.SingletonPlugin, DefaultDatasetForm,
212212
SCHEMA_OPTION = 'scheming.dataset_schemas'
213213
FALLBACK_OPTION = 'scheming.dataset_fallback'
214214
SCHEMA_TYPE_FIELD = 'dataset_type'
215-
SCHEMA_FILTER_ORDER = ['product_type', 'organization', 'groups', 'tags', 'res_format', 'license_id']
216-
SCHEMA_FILTER_TITLES = [p.toolkit._('Datentyp'), p.toolkit._('Organizations'), p.toolkit._('Groups'), p.toolkit._('Tags'), p.toolkit._('Formats'), p.toolkit._('License')]
215+
# SCHEMA_FILTER_ORDER = ['product_type', 'organization', 'groups', 'tags', 'res_format', 'license_id']
216+
# SCHEMA_FILTER_TITLES = [p.toolkit._('Datentyp'), p.toolkit._('Organizations'), p.toolkit._('Groups'), p.toolkit._('Tags'), p.toolkit._('Formats'), p.toolkit._('License')]
217+
SCHEMA_FILTER_ORDER = ['product_type', 'temporal_coverage', 'organization', 'tags', 'res_format', 'license_id', ]
218+
SCHEMA_FILTER_TITLES = [p.toolkit._('Datentyp'), p.toolkit._('Zeitliche Abdeckung'), p.toolkit._('Organizations'), p.toolkit._('Tags'), p.toolkit._('Formats'), p.toolkit._('License')]
217219

218220
@classmethod
219221
def _store_instance(cls, self):
@@ -253,6 +255,7 @@ def get_filter_config(self):
253255
def dataset_facets(self, facets_dict, package_type):
254256
#facets_dict['type'] = p.toolkit._('Type')
255257
# Return the updated facet dict.
258+
query = model.Session.query(model.Package)
256259
return self.get_filter_config()
257260

258261
def organization_facets(self, facets_dict, organization_type, package_type):

ckanext/scheming/presets_klimakonform.json

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"validators": "not_empty scheming_valid_json_object",
9090
"form_snippet": "spatial_extent.html",
9191
"display_snippet": "json.html",
92-
"display_property": "dcat:Dataset/dct:spatial"
92+
"display_property": "dcat:Dataset/dct:spatial/dcat:bbox"
9393
}
9494
},
9595
{
@@ -142,6 +142,47 @@
142142
]
143143
}
144144
},
145+
{
146+
"preset_name": "product_type",
147+
"values": {
148+
"classes": [
149+
"col-md-8 no-padding"
150+
],
151+
"form_snippet": "fixed_select.html",
152+
"display_snippet": "select.html",
153+
"validators": "ignore_missing unicode scheming_choices_ignore_missing check_required_field",
154+
"choices": [
155+
{
156+
"value": "Klimaprojektion",
157+
"label": "Klimaprojektion"
158+
},
159+
{
160+
"value": "Beobachtungsdaten",
161+
"label": "Beobachtungsdaten"
162+
},
163+
{
164+
"value": "Hydrologische Daten",
165+
"label": "Hydrologische Daten"
166+
},
167+
{
168+
"value": "Geologische Daten",
169+
"label": "Geologische Daten"
170+
},
171+
{
172+
"value": "Geobasisdaten",
173+
"label": "Geobasisdaten"
174+
},
175+
{
176+
"value": "Landnutzungsdaten",
177+
"label": "Landnutzungsdaten"
178+
},
179+
{
180+
"value": "Oberflächen- /Geländemodelle",
181+
"label": "Oberflächen- /Geländemodelle"
182+
}
183+
]
184+
}
185+
},
145186
{
146187
"preset_name": "date_range_start",
147188
"values": {
@@ -164,6 +205,13 @@
164205
"form_snippet": "fixed_date.html"
165206
}
166207
},
208+
{
209+
"preset_name": "date_range_total",
210+
"values": {
211+
"form_snippet": null,
212+
"display_snippet": null
213+
}
214+
},
167215
{
168216
"preset_name": "single_dataset_ref",
169217
"values": {

ckanext/scheming/templates/package/snippets/package_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{# This provides a full page that renders a form for adding a dataset. It can
55
then itself be extended to add/remove blocks of functionality. #}
66
<form id="dataset-edit" class="dataset-form" method="post" action="{{ action }}" data-module="basic-form" novalidate>
7-
7+
{{ h.csrf_input() }}
88
{%- set schema = h.scheming_get_dataset_schema(dataset_type) -%}
99
{%- if not schema.skip_resources -%}
1010

ckanext/scheming/templates/scheming/form_snippets/spatial_extent.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
data-module="spatial-form"
3838
data-input_id="{{ id }}"
3939
data-extent="{{ value }}"
40-
data-module-site_url="{{ h.dump_json(h.url('/', locale='default', qualified=true)) }}"
40+
data-module-site_url="{{ h.dump_json(h.url_for('/', locale='default', qualified=true)) }}"
4141
data-module-map_config="{{ h.dump_json(map_config) }}">
4242
<div id="dataset-map-container"></div>
4343
</div>

ckanext/scheming/templates/scheming/package/snippets/additional_info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'owner_org',
1111
'temporal_start',
1212
'temporal_end',
13-
'spatial'
13+
'spatial_geom'
1414
] -%}
1515

1616
{% block package_additional_info %}

ckanext/scheming/templates/snippets/add_dataset.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
{% if group %}
77
{% link_for _('Add ' + dataset_type.title()), named_route='%s.new' % dataset_type, group=group, class_='btn btn-primary', icon='plus-square' %}
88
{% else %}
9-
{% link_for _('Add ' + dataset_type.title()), named_route='%s.new' % dataset_type, class_='btn btn-primary', icon='plus-square' %}
9+
{% if dataset_type.title() == 'Application' %}
10+
{% link_for _('Klimadienst hinzufügen'), named_route='%s.new' % dataset_type, class_='btn btn-primary', icon='plus-square' %}
11+
{% else %}
12+
{% link_for _('Add ' + dataset_type.title()), named_route='%s.new' % dataset_type, class_='btn btn-primary', icon='plus-square' %}
13+
{% endif %}
1014
{% endif %}
1115
{% endfor %}

0 commit comments

Comments
 (0)