diff --git a/README.md b/README.md index 10e552829915b7ce75ebecb9845749729b317092..66ec9eed037341522588916fdaa46bd411f1ae98 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ Parameter | Type | Default | Description `ckanext.odsh.showtestbanner` | `boolean` | `True` | Switches on the banner "test system". Must be `false` for production server. `ckanext.odsh.language_mapping` | `string` | `/usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/resources/language_mapping.json` | Absolute path to language mapping file. `ckanext.odsh.spatial.mapping` | `string` | `/usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/resources/schleswig-holstein_geojson.csv` | Absolute path to spatial mapping file. The mapping file is expected to be a tab-separated file with three columns: URI, spatial text, and JSON geometry. +`ckanext.odsh.applicable_legislation` | `string` | `/usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/resources/applicable_legislation.json` | Absolute path to applicable legislation mapping file. +`ckanext.odsh.hvd_categories` | `string` | `/usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/resources/hvd_categories.json` | Absolute path to HVD category mapping file. `ckanext.odsh.resource_formats_fallback_filepath` | `string` | `/usr/lib/ckan/default/src/ckanext-odsh/ckanext/odsh/resources/fileformats.rdf` | Absolute path to resource formats fallback file. `ckanext.odsh.require_at_least_one_category` | `boolean` | `False` | Indicates whether the presence of at least one category is required during validation. `ckanext.odsh.require_spatial_uri` | `boolean` | `False` | Indicates whether a spatial URI is required for the dataset. diff --git a/ckanext/odsh/assets/odsh.css b/ckanext/odsh/assets/odsh.css index 6263fbff54c70991e6464ff232747407d617afc3..82ec970af528a324935d6440c9521a80285d870b 100644 --- a/ckanext/odsh/assets/odsh.css +++ b/ckanext/odsh/assets/odsh.css @@ -970,9 +970,9 @@ ul.dataset-resources { } .popover { - width: unset; - display: inline-table !important; - white-space: nowrap; + width: 350px; + max-width: 85vw; + display: inline-block !important; } a.odsh-star { @@ -3094,4 +3094,18 @@ section, .section { li.resource-item:hover .resource-description .ellipsis-action > .ellipsis-overlay { background-color: #EEEEEE; background: linear-gradient(to bottom,#EEEEEE 0%,rgba(255,255,255,0) 1%,#EEEEEE 100%); -} \ No newline at end of file +} + +.inline-list { + display: inline; + list-style: none; + padding: 0; +} + +ul.inline-list > li:not(:last-child)::after { + content: ", "; +} + +ul.inline-list > li { + display: inline; +} diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index 7ade4ebf635951d0eb643dac2ae6a94bd8cdc40b..bc8dea9ec0811b83eb85dafa8074cf77cb597858 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -15,6 +15,7 @@ import urllib.parse import urllib.error import hashlib import re +import os import csv from ckan.common import config, request, g, c from urllib.parse import urlsplit, urlunsplit @@ -22,7 +23,6 @@ import ckan.lib.helpers as helpers from collections import OrderedDict import pkg_resources - CKAN_TYPES = {'http://dcat-ap.de/def/datasetTypes/collection': 'collection'} get_action = logic.get_action @@ -501,6 +501,48 @@ def short_name_for_category(category_name): return translations.get(category_name) +def _load_mapping(mapping_file_path, uri=None): + result = None + try: + with open(mapping_file_path) as mapping_json: + MAPPING = json.load(mapping_json, object_pairs_hook=OrderedDict) + + if uri: + # Filter MAPPING to find the entry with the matching uri + filtered_entries = [entry for entry in MAPPING if entry.get('uri') == uri] + result = filtered_entries[0] if filtered_entries else None + else: + # If no uri provided, return all entries in key/value format (used in form) + result = [{'key': entry['uri'], 'value': entry.get('short_title', entry['title'])} for entry in MAPPING] + except FileNotFoundError: + print("File not found or path is incorrect.") + except json.JSONDecodeError: + print("Error decoding JSON.") + + return result + +def odsh_load_applicable_legislations(uri=None): + ''' + Load applicable legislations. + ''' + + extension_path = pkg_resources.resource_filename('ckanext.odsh', '') + default_mapping_file_path = os.path.join(extension_path, 'resources', 'applicable_legislations.json') + mapping_file_path = config.get('ckanext.odsh.applicable_legislations_file_path', default_mapping_file_path) + + return _load_mapping(mapping_file_path, uri) + +def odsh_load_hvd_categories(uri=None): + ''' + Load HVD categories. + ''' + + extension_path = pkg_resources.resource_filename('ckanext.odsh', '') + default_mapping_file_path = os.path.join(extension_path, 'resources', 'hvd_categories.json') + mapping_file_path = config.get('ckanext.odsh.hvd_categories_file_path', default_mapping_file_path) + + return _load_mapping(mapping_file_path, uri) + def odsh_load_mdk_sample_dataset(): ''' Load sample dataset (Musterkatalog/Musterdatensatz). @@ -518,7 +560,7 @@ def odsh_load_mdk_sample_dataset(): with open(sample_data_file_path) as mapping_json: MDK_MAPPING = json.loads( mapping_json.read(), object_pairs_hook=OrderedDict) - default = [{'value': 'Musterdatensatz wählen..', 'key': ''}] + default = [{'value': toolkit._('Select sample dataset..'), 'key': ''}] mdk = [{'key': key, 'value': MDK_MAPPING[key]} for key in MDK_MAPPING] result = default+mdk @@ -689,6 +731,8 @@ def get_spatial_for_selection(): spatial_mapping = list(cr) unique_mapping = [] + + unique_mapping.append({'value': toolkit._('Select spatial reference..'), 'key': ''}) seen_values = set() for key, value, _ in spatial_mapping: if value in seen_values: @@ -714,7 +758,6 @@ def get_spatial_for_selection(): seen_values.add(value) - unique_mapping.append({'key': '', 'value': ''}) return unique_mapping @@ -796,12 +839,12 @@ def format_resource_format(format_str): def extract_email(text): if not isinstance(text, str): return None # Return None for non-string inputs - + # Regular expression pattern to match email addresses email_pattern = r'[\w\.-]+@[a-zA-Z\d\.-]+\.[a-zA-Z]{2,}' - + # Find all email addresses in the input text using the regular expression pattern matches = re.findall(email_pattern, text) - + # If there are matches, return the first email address found, else return None - return matches[0] if matches else None \ No newline at end of file + return matches[0] if matches else None diff --git a/ckanext/odsh/i18n/ckanext-odsh.pot b/ckanext/odsh/i18n/ckanext-odsh.pot index 488cb5d1e974ca531634943ea20326d03941e50b..a76c27f60d180a735446cc40d6b6f46bfc61342a 100644 --- a/ckanext/odsh/i18n/ckanext-odsh.pot +++ b/ckanext/odsh/i18n/ckanext-odsh.pot @@ -1,14 +1,14 @@ # Translations template for ckanext-odsh. -# Copyright (C) 2023 ORGANIZATION +# Copyright (C) 2024 ORGANIZATION # This file is distributed under the same license as the ckanext-odsh project. -# FIRST AUTHOR <EMAIL@ADDRESS>, 2023. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2024. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: ckanext-odsh 2.3.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-11-06 12:35+0100\n" +"POT-Creation-Date: 2024-03-04 13:06+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -17,7 +17,15 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.10.3\n" -#: ckanext/odsh/plugin.py:232 ckanext/odsh/plugin.py:241 ckanext/odsh/plugin.py:247 +#: ckanext/odsh/helpers.py:563 +msgid "Select sample dataset.." +msgstr "" + +#: ckanext/odsh/helpers.py:735 +msgid "Select spatial reference.." +msgstr "" + +#: ckanext/odsh/plugin.py:248 ckanext/odsh/plugin.py:257 ckanext/odsh/plugin.py:263 #: ckanext/odsh/templates/header.html:40 #: ckanext/odsh/templates/organization/index.html:3 #: ckanext/odsh/templates/organization/index.html:6 @@ -28,31 +36,31 @@ msgstr "" msgid "Organizations" msgstr "" -#: ckanext/odsh/plugin.py:233 ckanext/odsh/plugin.py:244 ckanext/odsh/plugin.py:250 +#: ckanext/odsh/plugin.py:249 ckanext/odsh/plugin.py:260 ckanext/odsh/plugin.py:266 msgid "Category" msgstr "" -#: ckanext/odsh/plugin.py:234 ckanext/odsh/plugin.py:242 ckanext/odsh/plugin.py:248 +#: ckanext/odsh/plugin.py:250 ckanext/odsh/plugin.py:258 ckanext/odsh/plugin.py:264 msgid "File format" msgstr "" -#: ckanext/odsh/plugin.py:235 ckanext/odsh/plugin.py:243 ckanext/odsh/plugin.py:249 +#: ckanext/odsh/plugin.py:251 ckanext/odsh/plugin.py:259 ckanext/odsh/plugin.py:265 #: ckanext/odsh/templates/package/resource_read.html:162 #: ckanext/odsh/templates/package/snippets/info.html:75 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:111 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:118 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:110 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:117 msgid "License" msgstr "" -#: ckanext/odsh/plugin.py:237 +#: ckanext/odsh/plugin.py:253 msgid "Open-Data-Eigenschaften" msgstr "" -#: ckanext/odsh/validation.py:286 +#: ckanext/odsh/validation.py:290 msgid "Only formats on the list of the EU Publications Office are allowed." msgstr "" -#: ckanext/odsh/validation.py:296 +#: ckanext/odsh/validation.py:301 #, python-format msgid "Invalid tag: \"%s\". Tags cannot contain line breaks." msgstr "" @@ -75,12 +83,12 @@ msgid "Upload" msgstr "" #: ckanext/odsh/assets/odsh_image-upload.js:75 -#: ckanext/odsh/templates/macros/form.html:357 +#: ckanext/odsh/templates/macros/form.html:356 msgid "Remove" msgstr "" #: ckanext/odsh/assets/odsh_image-upload.js:83 -#: ckanext/odsh/templates/macros/form.html:564 +#: ckanext/odsh/templates/macros/form.html:563 msgid "Image" msgstr "" @@ -346,7 +354,7 @@ msgid "Raumbezug: Fehlender Wert" msgstr "" #: ckanext/odsh/templates/i18n_defaults.html:20 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:239 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:238 msgid "Tags" msgstr "" @@ -428,33 +436,33 @@ msgstr "" msgid "Discover datasets" msgstr "" -#: ckanext/odsh/templates/macros/form.html:410 +#: ckanext/odsh/templates/macros/form.html:409 msgid "Custom" msgstr "" -#: ckanext/odsh/templates/macros/form.html:410 +#: ckanext/odsh/templates/macros/form.html:409 #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:80 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:112 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:163 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:209 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:260 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:307 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:111 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:162 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:208 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:259 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:306 msgid "This field is required" msgstr "" -#: ckanext/odsh/templates/macros/form.html:546 +#: ckanext/odsh/templates/macros/form.html:545 msgid "Required field" msgstr "" -#: ckanext/odsh/templates/macros/form.html:562 +#: ckanext/odsh/templates/macros/form.html:561 msgid "http://example.com/my-image.jpg" msgstr "" -#: ckanext/odsh/templates/macros/form.html:563 +#: ckanext/odsh/templates/macros/form.html:562 msgid "Image URL" msgstr "" -#: ckanext/odsh/templates/macros/form.html:580 +#: ckanext/odsh/templates/macros/form.html:579 msgid "Clear Upload" msgstr "" @@ -552,25 +560,25 @@ msgid "A little information about my organization..." msgstr "" #: ckanext/odsh/templates/organization/snippets/organization_form.html:57 -#: ckanext/odsh/templates/organization/snippets/organization_form.html:75 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:76 msgid "Custom Field" msgstr "" -#: ckanext/odsh/templates/organization/snippets/organization_form.html:88 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:89 msgid "" "Are you sure you want to delete this Organization? Note*: Deleting cannot be " "performed while public or private datasets belong to this organization." msgstr "" -#: ckanext/odsh/templates/organization/snippets/organization_form.html:88 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:89 #: ckanext/odsh/templates/package/edit_view.html:19 -#: ckanext/odsh/templates/package/snippets/package_form.html:33 +#: ckanext/odsh/templates/package/snippets/package_form.html:32 #: ckanext/odsh/templates/package/snippets/resource_form.html:92 #: ckanext/odsh/templates/user/edit_user_form.html:84 msgid "Delete" msgstr "" -#: ckanext/odsh/templates/organization/snippets/organization_form.html:91 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:92 msgid "Save Organization" msgstr "" @@ -669,7 +677,7 @@ msgid "Draft" msgstr "" #: ckanext/odsh/templates/package/read.html:41 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:290 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:289 #: ckanext/odsh/templates/snippets/organization.html:24 #: ckanext/odsh/templates/snippets/package_item.html:83 msgid "Deleted" @@ -680,7 +688,7 @@ msgid "Manage Dataset" msgstr "" #: ckanext/odsh/templates/package/read.html:54 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:266 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:265 #: ckanext/odsh/templates/snippets/package_item.html:70 msgid "Private" msgstr "" @@ -704,12 +712,12 @@ msgid "" msgstr "" #: ckanext/odsh/templates/package/read.html:93 -#: ckanext/odsh/templates/package/snippets/resource_item.html:28 +#: ckanext/odsh/templates/package/snippets/resource_item.html:29 msgid "Read more »" msgstr "" #: ckanext/odsh/templates/package/read.html:94 -#: ckanext/odsh/templates/package/snippets/resource_item.html:29 +#: ckanext/odsh/templates/package/snippets/resource_item.html:30 msgid "« Read less" msgstr "" @@ -842,12 +850,12 @@ msgstr "" #: ckanext/odsh/templates/package/search.html:69 #: ckanext/odsh/templates/package/snippets/info.html:52 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:163 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:162 msgid "Period" msgstr "" #: ckanext/odsh/templates/package/search.html:79 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:176 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:175 #: ckanext/odsh/templates/snippets/search_form.html:115 msgid "from" msgstr "" @@ -867,7 +875,7 @@ msgid "wrong_start_date_for_search" msgstr "" #: ckanext/odsh/templates/package/search.html:94 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:190 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:189 #: ckanext/odsh/templates/snippets/search_form.html:142 msgid "to" msgstr "" @@ -933,37 +941,65 @@ msgstr "" msgid "Modified" msgstr "" -#: ckanext/odsh/templates/package/snippets/info.html:89 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:349 -msgid "Musterdatensatz" +#: ckanext/odsh/templates/package/snippets/info.html:88 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:343 +msgid "Sample Dataset" msgstr "" #: ckanext/odsh/templates/package/snippets/info.html:99 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:254 -msgid "Spatial uri" +msgid "Applicable Legislation:" +msgid_plural "Applicable Legislation:" +msgstr[0] "" +msgstr[1] "" + +#: ckanext/odsh/templates/package/snippets/info.html:120 +msgid "HVD Category:" +msgid_plural "HVD Categories:" +msgstr[0] "" +msgstr[1] "" + +#: ckanext/odsh/templates/package/snippets/info.html:125 +msgid "" +"<p>The EU Commission has published a list of particularly high-value datasets" +" (HVD - High Value Datasets), which public authorities must make available " +"free of charge and under an open license. Datasets are considered high-value " +"if they "have a special potential for generating socio-economic benefits" +" in connection with harmonized conditions for re-use". They are divided " +"into six categories.</p><p><a " +"href='https://www.govdata.de/web/guest/neues/-/blogs/hochwertige-" +"datensatze'>More about HVD at the national Open Data Portal GovData.</a></p>" +msgstr "" + +#: ckanext/odsh/templates/package/snippets/info.html:125 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:355 +msgid "HVD Category" +msgstr "" + +#: ckanext/odsh/templates/package/snippets/info.html:143 +msgid "Spatial URI" msgstr "" -#: ckanext/odsh/templates/package/snippets/info.html:113 +#: ckanext/odsh/templates/package/snippets/info.html:157 msgid "Map boundaries" msgstr "" -#: ckanext/odsh/templates/package/snippets/info.html:114 +#: ckanext/odsh/templates/package/snippets/info.html:158 msgid "in east" msgstr "" -#: ckanext/odsh/templates/package/snippets/info.html:115 +#: ckanext/odsh/templates/package/snippets/info.html:159 msgid "in west" msgstr "" -#: ckanext/odsh/templates/package/snippets/info.html:116 +#: ckanext/odsh/templates/package/snippets/info.html:160 msgid "in north" msgstr "" -#: ckanext/odsh/templates/package/snippets/info.html:117 +#: ckanext/odsh/templates/package/snippets/info.html:161 msgid "in south" msgstr "" -#: ckanext/odsh/templates/package/snippets/info.html:123 +#: ckanext/odsh/templates/package/snippets/info.html:167 msgid "DCAT-AP.de metadata" msgstr "" @@ -989,49 +1025,55 @@ msgid "Organization" msgstr "" #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:87 -msgid "" -"No\n" -" organization" +msgid "No organization" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:138 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:137 #: ckanext/odsh/templates/user/snippets/login_form.html:23 msgid "enter name" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:209 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:208 msgid "Publication date" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:245 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:244 msgid "odsh tags placeholder" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:259 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:253 +msgid "Spatial uri" +msgstr "" + +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:258 msgid "Visibility" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:266 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:265 msgid "Public" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:280 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:279 msgid "State" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:287 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:286 msgid "Active" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_form.html:32 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:349 +msgid "Applicable Legislation" +msgstr "" + +#: ckanext/odsh/templates/package/snippets/package_form.html:31 msgid "Are you sure you want to delete this dataset?" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_form.html:39 +#: ckanext/odsh/templates/package/snippets/package_form.html:37 msgid "Next: Add Data" msgstr "" -#: ckanext/odsh/templates/package/snippets/package_form.html:46 +#: ckanext/odsh/templates/package/snippets/package_form.html:44 #: ckanext/odsh/templates/package/snippets/resource_form.html:119 msgid "Required information" msgstr "" @@ -1131,15 +1173,15 @@ msgstr "" msgid "Resource count" msgstr "" -#: ckanext/odsh/templates/package/snippets/resource_item.html:33 +#: ckanext/odsh/templates/package/snippets/resource_item.html:34 msgid "File size" msgstr "" -#: ckanext/odsh/templates/package/snippets/resource_item.html:37 +#: ckanext/odsh/templates/package/snippets/resource_item.html:38 msgid "Number of pages" msgstr "" -#: ckanext/odsh/templates/package/snippets/resource_item.html:43 +#: ckanext/odsh/templates/package/snippets/resource_item.html:45 msgid "download file" msgstr "" diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo index ec867b922cc9903c538c9d64fb2508e74012c98c..464135e07573468544167fa5d222e49ba2a97fbf 100644 Binary files a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo and b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo differ diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po index 147f24d588c8832d009e7b1bc35e9c1b6c450b94..c2351059eb15b760e2a8a6be34c3f2b9edb797f1 100644 --- a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po +++ b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: ckanext-odsh 2.0.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-11-06 12:35+0100\n" -"PO-Revision-Date: 2023-11-06 12:40+0100\n" +"POT-Creation-Date: 2024-03-04 13:06+0100\n" +"PO-Revision-Date: 2024-03-04 13:09+0100\n" "Last-Translator: \n" "Language-Team: de <LL@li.org>\n" "Language: de\n" @@ -20,8 +20,16 @@ msgstr "" "Generated-By: Babel 2.3.4\n" "X-Generator: Poedit 3.0.1\n" -#: ckanext/odsh/plugin.py:232 ckanext/odsh/plugin.py:241 -#: ckanext/odsh/plugin.py:247 ckanext/odsh/templates/header.html:40 +#: ckanext/odsh/helpers.py:563 +msgid "Select sample dataset.." +msgstr "Musterdatensatz wählen.." + +#: ckanext/odsh/helpers.py:735 +msgid "Select spatial reference.." +msgstr "Raumbezug wählen.." + +#: ckanext/odsh/plugin.py:248 ckanext/odsh/plugin.py:257 +#: ckanext/odsh/plugin.py:263 ckanext/odsh/templates/header.html:40 #: ckanext/odsh/templates/organization/index.html:3 #: ckanext/odsh/templates/organization/index.html:6 #: ckanext/odsh/templates/organization/index.html:32 @@ -31,36 +39,36 @@ msgstr "" msgid "Organizations" msgstr "Herausgeber" -#: ckanext/odsh/plugin.py:233 ckanext/odsh/plugin.py:244 -#: ckanext/odsh/plugin.py:250 +#: ckanext/odsh/plugin.py:249 ckanext/odsh/plugin.py:260 +#: ckanext/odsh/plugin.py:266 msgid "Category" msgstr "Kategorie" -#: ckanext/odsh/plugin.py:234 ckanext/odsh/plugin.py:242 -#: ckanext/odsh/plugin.py:248 +#: ckanext/odsh/plugin.py:250 ckanext/odsh/plugin.py:258 +#: ckanext/odsh/plugin.py:264 msgid "File format" msgstr "Dateiformat" -#: ckanext/odsh/plugin.py:235 ckanext/odsh/plugin.py:243 -#: ckanext/odsh/plugin.py:249 +#: ckanext/odsh/plugin.py:251 ckanext/odsh/plugin.py:259 +#: ckanext/odsh/plugin.py:265 #: ckanext/odsh/templates/package/resource_read.html:162 #: ckanext/odsh/templates/package/snippets/info.html:75 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:111 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:118 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:110 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:117 msgid "License" msgstr "Lizenz" -#: ckanext/odsh/plugin.py:237 +#: ckanext/odsh/plugin.py:253 msgid "Open-Data-Eigenschaften" msgstr "Open-Data-Eigenschaften" -#: ckanext/odsh/validation.py:286 +#: ckanext/odsh/validation.py:290 msgid "Only formats on the list of the EU Publications Office are allowed." msgstr "" "Es sind nur Formate zulässig, die in der Liste des EU Publications Office " "aufgeführt sind." -#: ckanext/odsh/validation.py:296 +#: ckanext/odsh/validation.py:301 #, python-format msgid "Invalid tag: \"%s\". Tags cannot contain line breaks." msgstr "Ungültiges Tag: \"%s\". Tags können keine Zeilenumbrüche enthalten." @@ -85,12 +93,12 @@ msgid "Upload" msgstr "Upload" #: ckanext/odsh/assets/odsh_image-upload.js:75 -#: ckanext/odsh/templates/macros/form.html:357 +#: ckanext/odsh/templates/macros/form.html:356 msgid "Remove" msgstr "Entfernen" #: ckanext/odsh/assets/odsh_image-upload.js:83 -#: ckanext/odsh/templates/macros/form.html:564 +#: ckanext/odsh/templates/macros/form.html:563 msgid "Image" msgstr "Bild" @@ -361,7 +369,7 @@ msgid "Raumbezug: Fehlender Wert" msgstr "Bitte geben Sie einen Ort ein" #: ckanext/odsh/templates/i18n_defaults.html:20 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:239 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:238 msgid "Tags" msgstr "Schlagwörter" @@ -445,33 +453,33 @@ msgstr "" msgid "Discover datasets" msgstr "weitere Distribution" -#: ckanext/odsh/templates/macros/form.html:410 +#: ckanext/odsh/templates/macros/form.html:409 msgid "Custom" msgstr "Benutzerdefiniert" -#: ckanext/odsh/templates/macros/form.html:410 +#: ckanext/odsh/templates/macros/form.html:409 #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:80 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:112 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:163 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:209 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:260 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:307 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:111 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:162 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:208 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:259 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:306 msgid "This field is required" msgstr "Dieses Feld ist erforderlich" -#: ckanext/odsh/templates/macros/form.html:546 +#: ckanext/odsh/templates/macros/form.html:545 msgid "Required field" msgstr "Pflichtfeld" -#: ckanext/odsh/templates/macros/form.html:562 +#: ckanext/odsh/templates/macros/form.html:561 msgid "http://example.com/my-image.jpg" msgstr "http://example.com/my-image.jpg" -#: ckanext/odsh/templates/macros/form.html:563 +#: ckanext/odsh/templates/macros/form.html:562 msgid "Image URL" msgstr "URL des Bildes" -#: ckanext/odsh/templates/macros/form.html:580 +#: ckanext/odsh/templates/macros/form.html:579 msgid "Clear Upload" msgstr "Upload zurücksetzen" @@ -569,11 +577,11 @@ msgid "A little information about my organization..." msgstr "Ein paar Informationen über diesen Herausgeber..." #: ckanext/odsh/templates/organization/snippets/organization_form.html:57 -#: ckanext/odsh/templates/organization/snippets/organization_form.html:75 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:76 msgid "Custom Field" msgstr "Benutzerdefiniert" -#: ckanext/odsh/templates/organization/snippets/organization_form.html:88 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:89 msgid "" "Are you sure you want to delete this Organization? Note*: Deleting cannot be " "performed while public or private datasets belong to this organization." @@ -582,15 +590,15 @@ msgstr "" "alle öffentlichen und privaten Datensätze, die zu diesem Herausgeber " "gehören, gelöscht." -#: ckanext/odsh/templates/organization/snippets/organization_form.html:88 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:89 #: ckanext/odsh/templates/package/edit_view.html:19 -#: ckanext/odsh/templates/package/snippets/package_form.html:33 +#: ckanext/odsh/templates/package/snippets/package_form.html:32 #: ckanext/odsh/templates/package/snippets/resource_form.html:92 #: ckanext/odsh/templates/user/edit_user_form.html:84 msgid "Delete" msgstr "Löschen" -#: ckanext/odsh/templates/organization/snippets/organization_form.html:91 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:92 msgid "Save Organization" msgstr "Herausgeber speichern" @@ -695,7 +703,7 @@ msgid "Draft" msgstr "Entwurf" #: ckanext/odsh/templates/package/read.html:41 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:290 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:289 #: ckanext/odsh/templates/snippets/organization.html:24 #: ckanext/odsh/templates/snippets/package_item.html:83 msgid "Deleted" @@ -706,7 +714,7 @@ msgid "Manage Dataset" msgstr "Datensatz bearbeiten" #: ckanext/odsh/templates/package/read.html:54 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:266 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:265 #: ckanext/odsh/templates/snippets/package_item.html:70 msgid "Private" msgstr "Privat" @@ -734,12 +742,12 @@ msgstr "" "href=\"%(is_replaced_by)s\">neuere Version</a> ersetzt." #: ckanext/odsh/templates/package/read.html:93 -#: ckanext/odsh/templates/package/snippets/resource_item.html:28 +#: ckanext/odsh/templates/package/snippets/resource_item.html:29 msgid "Read more »" msgstr "Mehr erfahren »" #: ckanext/odsh/templates/package/read.html:94 -#: ckanext/odsh/templates/package/snippets/resource_item.html:29 +#: ckanext/odsh/templates/package/snippets/resource_item.html:30 msgid "« Read less" msgstr "« Weniger anzeigen" @@ -882,12 +890,12 @@ msgstr "Format" #: ckanext/odsh/templates/package/search.html:69 #: ckanext/odsh/templates/package/snippets/info.html:52 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:163 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:162 msgid "Period" msgstr "Zeitraum" #: ckanext/odsh/templates/package/search.html:79 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:176 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:175 #: ckanext/odsh/templates/snippets/search_form.html:115 msgid "from" msgstr "von" @@ -907,7 +915,7 @@ msgid "wrong_start_date_for_search" msgstr "Das Startdatum ist ungültig" #: ckanext/odsh/templates/package/search.html:94 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:190 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:189 #: ckanext/odsh/templates/snippets/search_form.html:142 msgid "to" msgstr "bis" @@ -973,37 +981,74 @@ msgstr "Veröffentlicht" msgid "Modified" msgstr "Zuletzt bearbeitet" -#: ckanext/odsh/templates/package/snippets/info.html:89 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:349 -msgid "Musterdatensatz" +#: ckanext/odsh/templates/package/snippets/info.html:88 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:343 +msgid "Sample Dataset" msgstr "Musterdatensatz" #: ckanext/odsh/templates/package/snippets/info.html:99 -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:254 -msgid "Spatial uri" +msgid "Applicable Legislation:" +msgid_plural "Applicable Legislation:" +msgstr[0] "Geltende Rechtsvorschrift:" +msgstr[1] "Geltende Rechtsvorschriften:" + +#: ckanext/odsh/templates/package/snippets/info.html:120 +msgid "HVD Category:" +msgid_plural "HVD Categories:" +msgstr[0] "HVD-Kategorie:" +msgstr[1] "HVD-Kategorien" + +#: ckanext/odsh/templates/package/snippets/info.html:125 +msgid "" +"<p>The EU Commission has published a list of particularly high-value " +"datasets (HVD - High Value Datasets), which public authorities must make " +"available free of charge and under an open license. Datasets are considered " +"high-value if they "have a special potential for generating socio-" +"economic benefits in connection with harmonized conditions for re-use". " +"They are divided into six categories.</p><p><a href='https://www.govdata.de/" +"web/guest/neues/-/blogs/hochwertige-datensatze'>More about HVD at the " +"national Open Data Portal GovData.</a></p>" +msgstr "" +"<p>Die EU-Kommission hat eine Liste besonders hochwertiger Datensätze (High " +"Value Datasets, kurz: HVD) veröffentlicht, die öffentliche Stellen kostenlos " +"und in einer offenen Lizenz zur Verfügung stellen muss. Als hochwertig " +"werden Datensätze angesehen, die "einem besonderen Potenzial für die " +"Erzielung sozioökonomischer Vorteile in Verbindung mit harmonisierten " +"Bedingungen für die Weiterverwendung" haben. Sie werden in die sechs " +"Kategorien eingeteilt.</p><p><a href='https://www.govdata.de/web/guest/" +"neues/-/blogs/hochwertige-datensatze'>Mehr zu HVD beim nationalen Open-Data-" +"Portal GovData.</a></p>" + +#: ckanext/odsh/templates/package/snippets/info.html:125 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:355 +msgid "HVD Category" +msgstr "HVD-Kategorie" + +#: ckanext/odsh/templates/package/snippets/info.html:143 +msgid "Spatial URI" msgstr "Raumbezug" -#: ckanext/odsh/templates/package/snippets/info.html:113 +#: ckanext/odsh/templates/package/snippets/info.html:157 msgid "Map boundaries" msgstr "Grenzen der Karte" -#: ckanext/odsh/templates/package/snippets/info.html:114 +#: ckanext/odsh/templates/package/snippets/info.html:158 msgid "in east" msgstr "im Osten" -#: ckanext/odsh/templates/package/snippets/info.html:115 +#: ckanext/odsh/templates/package/snippets/info.html:159 msgid "in west" msgstr "im Westen" -#: ckanext/odsh/templates/package/snippets/info.html:116 +#: ckanext/odsh/templates/package/snippets/info.html:160 msgid "in north" msgstr "im Norden" -#: ckanext/odsh/templates/package/snippets/info.html:117 +#: ckanext/odsh/templates/package/snippets/info.html:161 msgid "in south" msgstr "im Süden" -#: ckanext/odsh/templates/package/snippets/info.html:123 +#: ckanext/odsh/templates/package/snippets/info.html:167 msgid "DCAT-AP.de metadata" msgstr "Metadaten nach DCAT-AP.de" @@ -1017,8 +1062,6 @@ msgid "Enter title" msgstr "Titel eingeben" #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:37 -#, fuzzy -#| msgid "dataset" msgid "eg. my-dataset" msgstr "Datensatz" @@ -1031,49 +1074,57 @@ msgid "Organization" msgstr "Herausgeber" #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:87 -msgid "" -"No\n" -" organization" -msgstr "Kein Herausgeber" +#, fuzzy +#| msgid "Organization" +msgid "No organization" +msgstr "Herausgeber" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:138 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:137 #: ckanext/odsh/templates/user/snippets/login_form.html:23 msgid "enter name" msgstr "Name eingeben" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:209 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:208 msgid "Publication date" msgstr "Publikationsdatum" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:245 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:244 msgid "odsh tags placeholder" msgstr "z.B. Energie; Politik; Umwelt; Alle; ..." -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:259 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:253 +msgid "Spatial uri" +msgstr "Raumbezug" + +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:258 msgid "Visibility" msgstr "Sichtbarkeit" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:266 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:265 msgid "Public" msgstr "Öffentlich" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:280 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:279 msgid "State" msgstr "Status" -#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:287 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:286 msgid "Active" msgstr "Aktiv" -#: ckanext/odsh/templates/package/snippets/package_form.html:32 +#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:349 +msgid "Applicable Legislation" +msgstr "Geltende Rechtsvorschriften" + +#: ckanext/odsh/templates/package/snippets/package_form.html:31 msgid "Are you sure you want to delete this dataset?" msgstr "Sind Sie sicher, dass Sie diesen Datensatz löschen wollen?" -#: ckanext/odsh/templates/package/snippets/package_form.html:39 +#: ckanext/odsh/templates/package/snippets/package_form.html:37 msgid "Next: Add Data" msgstr "Weiter: Daten hinzufügen" -#: ckanext/odsh/templates/package/snippets/package_form.html:46 +#: ckanext/odsh/templates/package/snippets/package_form.html:44 #: ckanext/odsh/templates/package/snippets/resource_form.html:119 msgid "Required information" msgstr "Pflichtangabe" @@ -1140,10 +1191,6 @@ msgid "eg. application/json" msgstr "z.B. application/json" #: ckanext/odsh/templates/package/snippets/resource_form.html:60 -#, fuzzy -#| msgid "" -#| "eg.\n" -#| " application/json" msgid "" "eg.\n" " application/json" @@ -1177,15 +1224,15 @@ msgstr "Name Ressource" msgid "Resource count" msgstr "Anzahl Ressourcen" -#: ckanext/odsh/templates/package/snippets/resource_item.html:33 +#: ckanext/odsh/templates/package/snippets/resource_item.html:34 msgid "File size" msgstr "Dateigröße" -#: ckanext/odsh/templates/package/snippets/resource_item.html:37 +#: ckanext/odsh/templates/package/snippets/resource_item.html:38 msgid "Number of pages" msgstr "Seitenanzahl" -#: ckanext/odsh/templates/package/snippets/resource_item.html:43 +#: ckanext/odsh/templates/package/snippets/resource_item.html:45 msgid "download file" msgstr "Datei herunterladen" @@ -1545,6 +1592,36 @@ msgstr "Einloggen" msgid "Not authorized to see this page" msgstr "Nicht berechtigt, diese Seite zu sehen" +#~ msgid "" +#~ "A High-Value Dataset (HVD) category refers to a group of datasets that " +#~ "are considered particularly important and valuable. These datasets cover " +#~ "various topics such as maps, environmental data, weather information, " +#~ "statistics, company details, and data related to transportation. The " +#~ "European Commission has identified six main categories of these high-" +#~ "value datasets to ensure that they are easily accessible and useful for " +#~ "different purposes. These categories help to organize and prioritize " +#~ "datasets that have the potential to significantly benefit European " +#~ "citizens and businesses." +#~ msgstr "" +#~ "Eine High-Value-Dataset (HVD)-Kategorie bezieht sich auf eine Gruppe von " +#~ "Datensätzen, die als besonders wichtig und wertvoll betrachtet werden. " +#~ "Diese Datensätze decken verschiedene Themen ab, wie zum Beispiel Karten, " +#~ "Umweltdaten, Wetterinformationen, Statistiken, Unternehmensdetails und " +#~ "Daten im Zusammenhang mit dem Transport. Die Europäische Kommission hat " +#~ "sechs Hauptkategorien dieser hochwertigen Datensätze identifiziert, um " +#~ "sicherzustellen, dass sie leicht zugänglich und nützlich für verschiedene " +#~ "Zwecke sind. Diese Kategorien helfen dabei, Datensätze zu organisieren " +#~ "und zu priorisieren, die das Potenzial haben, europäischen Bürgern und " +#~ "Unternehmen erhebliche Vorteile zu bringen." + +#~ msgid "HVD Categories" +#~ msgstr "HVD-Kategorien" + +#~ msgid "" +#~ "No\n" +#~ " organization" +#~ msgstr "Kein Herausgeber" + #~ msgid "Contact Person" #~ msgstr "Ansprechstelle" @@ -1716,9 +1793,6 @@ msgstr "Nicht berechtigt, diese Seite zu sehen" #~ msgid "back" #~ msgstr "zurück" -#~ msgid "Kategorie" -#~ msgstr "Kategorie" - #, fuzzy #~| msgid "Add dataset" #~ msgid "Add Dataset" diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index e71e23225605276ea1671b512ae911b56021bec7..2078ae169b16e1f94f871656b518cfc91eb775eb 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -3,12 +3,12 @@ from dateutil.parser import parse import json import logging from collections import OrderedDict +from ckan.types import Schema # imports from ckan -from ckan.lib.plugins import DefaultTranslation, DefaultDatasetForm -from ckan.logic.validators import tag_string_convert -import ckan.plugins as plugins -import ckan.plugins.toolkit as toolkit +from ckan.lib.plugins import DefaultTranslation +import ckan.plugins as p +import ckan.plugins.toolkit as tk # imports from this extension import ckanext.odsh.helpers as helpers_odsh @@ -28,20 +28,20 @@ from ckanext.odsh.views import feed log = logging.getLogger(__name__) -_ = toolkit._ +_ = tk._ -class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm): - plugins.implements(plugins.IActions) - plugins.implements(plugins.IConfigurer) - plugins.implements(plugins.IDatasetForm) - plugins.implements(plugins.IFacets) - plugins.implements(plugins.IPackageController, inherit=True) - plugins.implements(plugins.ITemplateHelpers) - plugins.implements(plugins.ITranslation) - plugins.implements(plugins.IValidators) - plugins.implements(plugins.IResourceController, inherit=True) - plugins.implements(plugins.IBlueprint) +class OdshPlugin(p.SingletonPlugin, DefaultTranslation, tk.DefaultDatasetForm): + p.implements(p.IActions) + p.implements(p.IConfigurer) + p.implements(p.IDatasetForm) + p.implements(p.IFacets) + p.implements(p.IPackageController, inherit=True) + p.implements(p.ITemplateHelpers) + p.implements(p.ITranslation) + p.implements(p.IValidators) + p.implements(p.IResourceController, inherit=True) + p.implements(p.IBlueprint) # IBlueprint def get_blueprint(self): @@ -58,7 +58,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm bp_default.add_url_rule(*rule) # DCAT - # if toolkit.asbool(toolkit.config.get('ckanext.dcat.enable_rdf_endpoints', True)): + # if tk.asbool(tk.config.get('ckanext.dcat.enable_rdf_endpoints', True)): # helpers_odsh.odsh_remove_route(map, 'dcat_catalog') # bp_default.add_url_rule('/catalog.<any("xml", "rdf", "n3", "ttl", "jsonld"):_format>', view_func=dcat_view.read_catalog, defaults={'_format': 'xml'}, methods=['GET']) @@ -108,9 +108,9 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm # IConfigurer def update_config(self, config_): - toolkit.add_template_directory(config_, 'templates') - toolkit.add_public_directory(config_, 'public') - toolkit.add_resource('assets', 'ckanext-odsh') + tk.add_template_directory(config_, 'templates') + tk.add_public_directory(config_, 'public') + tk.add_resource('assets', 'ckanext-odsh') def after_map(self, map): return map @@ -125,103 +125,119 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm # package types not handled by any other IDatasetForm plugin. return True - def create_package_schema(self): - schema = super(OdshPlugin, self).create_package_schema() - self._update_schema(schema) - self._update_create_or_update_package_schema(schema) + def create_package_schema(self) -> Schema: + log.debug("OdshPlugin::create_package_schema") + schema: Schema = super(OdshPlugin, self).create_package_schema() + schema = self._update_schema(schema) + schema = self._update_create_or_update_package_schema(schema) return schema - def update_package_schema(self): - schema = super(OdshPlugin, self).update_package_schema() - self._update_schema(schema) - self._update_create_or_update_package_schema(schema) + def update_package_schema(self) -> Schema: + log.debug("OdshPlugin::update_package_schema") + schema: Schema = super(OdshPlugin, self).update_package_schema() + schema = self._update_schema(schema) + schema = self._update_create_or_update_package_schema(schema) return schema - def show_package_schema(self): - schema = super(OdshPlugin, self).show_package_schema() - self._update_show_package_schema(schema) + def show_package_schema(self) -> Schema: + log.debug("OdshPlugin::show_package_schema") + schema: Schema = super(OdshPlugin, self).show_package_schema() + schema = self._update_show_package_schema(schema) return schema - def _update_schema(self, schema): + def _update_schema(self, schema: Schema) -> Schema: for field in ['title', 'license_id']: - schema.update({field: [toolkit.get_converter('not_empty')]}) + schema.update({field: [tk.get_converter('not_empty')]}) - for field in ['reference', 'is_replaced_by', 'version_notes']: + for field in ['reference','applicableLegislation','hvdCategory', 'is_replaced_by', 'version_notes']: schema.update({ field: [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_validator('ignore_missing'), + tk.get_converter('convert_to_extras') ] }) schema['resources'].update({ - 'url': [toolkit.get_converter('not_empty')], - 'format': [toolkit.get_converter('odsh_validate_format')], + 'url': [tk.get_converter('not_empty')], + 'format': [tk.get_converter('odsh_validate_format')], }) schema['extras'].update({ 'key': [ - toolkit.get_converter('known_spatial_uri'), - toolkit.get_converter('validate_licenseAttributionByText'), + tk.get_converter('known_spatial_uri'), + tk.get_converter('validate_licenseAttributionByText'), ] }) schema.update( - {'__extras': [toolkit.get_converter('odsh_validate_extras')]}) + {'__extras': [tk.get_converter('odsh_validate_extras')]}) + return schema - def _update_create_or_update_package_schema(self, schema): + def _update_create_or_update_package_schema(self, schema: Schema) -> Schema: schema.update({ 'language': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_validator('ignore_missing'), + tk.get_converter('convert_to_extras') ], 'thumbnail': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_validator('ignore_missing'), + tk.get_converter('convert_to_extras') ], 'relatedPackage': [ - toolkit.get_validator('validate_relatedPackage'), - toolkit.get_converter('convert_to_extras') + tk.get_validator('validate_relatedPackage'), + tk.get_converter('convert_to_extras') ], 'accessibility': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_validator('ignore_missing'), + tk.get_converter('convert_to_extras') ], 'is_replaced_by': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_validator('ignore_missing'), + tk.get_converter('convert_to_extras') ], 'version_notes': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_validator('ignore_missing'), + tk.get_converter('convert_to_extras') ], }) return schema - def _update_show_package_schema(self, schema): + def _update_show_package_schema(self, schema: Schema) -> Schema: schema.update({ 'language': [ - toolkit.get_converter('convert_from_extras'), - toolkit.get_validator('ignore_missing') + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') ], 'thumbnail': [ - toolkit.get_converter('convert_from_extras'), - toolkit.get_validator('ignore_missing') + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') ], 'relatedPackage': [ - toolkit.get_converter('convert_from_extras'), - toolkit.get_validator('ignore_missing') + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') ], 'accessibility': [ - toolkit.get_converter('convert_from_extras'), - toolkit.get_validator('ignore_missing') + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') ], 'is_replaced_by': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') ], 'version_notes': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') + ], + 'reference': [ + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') + ], + 'hvdCategory': [ + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') + ], + 'applicableLegislation': [ + tk.get_converter('convert_from_extras'), + tk.get_validator('ignore_missing') ], }) return schema @@ -348,6 +364,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm 'get_resource_size': helpers_odsh.get_resource_size, 'get_address_org':helpers_odsh.get_address_org, 'get_body_mail':helpers_odsh.get_body_mail, + 'odsh_load_applicable_legislations': helpers_odsh.odsh_load_applicable_legislations, + 'odsh_load_hvd_categories': helpers_odsh.odsh_load_hvd_categories, 'odsh_load_mdk_sample_dataset': helpers_odsh.odsh_load_mdk_sample_dataset, 'odsh_load_raw_mdk_sample_dataset': helpers_odsh.odsh_load_raw_mdk_sample_dataset, 'format_resource_format': helpers_odsh.format_resource_format, diff --git a/ckanext/odsh/profiles/odsh_dcat_de_profile.py b/ckanext/odsh/profiles/odsh_dcat_de_profile.py index 517a66270f39437e6b180bb860aee0fa895ff14d..16b87f3b99c6f21d090d742d6b859756c8fae9ae 100644 --- a/ckanext/odsh/profiles/odsh_dcat_de_profile.py +++ b/ckanext/odsh/profiles/odsh_dcat_de_profile.py @@ -11,13 +11,18 @@ from ckanext.dcatde.profiles import DCATdeProfile, DCATDE, DCAT, DCATDE_1_0, DCA import ckanext.odsh.helpers as helpers_odsh import ckanext.odsh.collection.helpers as helpers_collection +import logging +log = logging.getLogger(__name__) DCT = rdflib.namespace.Namespace("http://purl.org/dc/terms/") DCAT = rdflib.namespace.Namespace("http://www.w3.org/ns/dcat#") -DCATDE_1_0_2 = rdflib.namespace.Namespace("http://dcat-ap.de/def/dcatde/1.0.2/") +DCATAP = rdflib.namespace.Namespace("http://data.europa.eu/r5r/") +DCATDE_1_0_2 = rdflib.namespace.Namespace( + "http://dcat-ap.de/def/dcatde/1.0.2/") ADMS = rdflib.namespace.Namespace("http://www.w3.org/ns/adms#") + class ODSHDCATdeProfile(DCATdeProfile): # from RDF @@ -29,6 +34,9 @@ class ODSHDCATdeProfile(DCATdeProfile): self._parse_distributions(dataset_dict, dataset_ref) self._parse_type(dataset_dict, dataset_ref) self._parse_references(dataset_dict, dataset_ref) + self._parse_applicable_legislation(dataset_dict, dataset_ref) + self._parse_hvd_category(dataset_dict, dataset_ref) + if self._belongs_to_collection(dataset_dict, dataset_ref): self._mark_for_adding_to_ckan_collection(dataset_dict, dataset_ref) return dataset_dict @@ -57,6 +65,45 @@ class ODSHDCATdeProfile(DCATdeProfile): if value: ds_utils.insert_new_extras_field(dataset_dict, 'reference', value) + def _parse_metadata_list(self, dataset_dict, dataset_ref, field_name, rdf_predicate): + value = "" + for obj in self.g.objects(dataset_ref, rdf_predicate): + if value: + value += "," + str(obj) + else: + value = str(obj) + if value: + ds_utils.insert_new_extras_field( + dataset_dict, field_name, "{" + value + "}") + + def _parse_applicable_legislation(self, dataset_dict, dataset_ref): + self._parse_metadata_list(dataset_dict, dataset_ref, 'applicableLegislation', DCATAP.applicableLegislation) + + def _parse_hvd_category(self, dataset_dict, dataset_ref): + self._parse_metadata_list(dataset_dict, dataset_ref, 'hvdCategory', DCATAP.hvdCategory) + + def _parse_applicable_legislation(self, dataset_dict, dataset_ref): + value = "" + for applicable_legislation in self.g.objects(dataset_ref, DCATAP.applicableLegislation): + if value: + value += "," + applicable_legislation + else: + value = applicable_legislation + if value: + ds_utils.insert_new_extras_field( + dataset_dict, 'applicableLegislation', "{" + value + "}") + + def _parse_hvd_category(self, dataset_dict, dataset_ref): + value = "" + for hvdCategory in self.g.objects(dataset_ref, DCATAP.hvdCategory): + if value: + value += "," + hvdCategory + else: + value = hvdCategory + if value: + ds_utils.insert_new_extras_field( + dataset_dict, 'hvdCategory', "{" + value + "}") + def _belongs_to_collection(self, dataset_dict, dataset_ref): dct_is_version_of = self._object(dataset_ref, DCT.isVersionOf) belongs_to_collection = True if dct_is_version_of else False @@ -80,7 +127,12 @@ class ODSHDCATdeProfile(DCATdeProfile): self._add_license_attribution_by_text(dataset_dict, dataset_ref) self._add_type(dataset_dict, dataset_ref) self._add_modified_and_issued(dataset_dict, dataset_ref) - self._add_references(dataset_dict, dataset_ref) + self._add_extra_field(dataset_dict, dataset_ref, + 'reference', DCT.references) + self._add_extra_field(dataset_dict, dataset_ref, + 'applicableLegislation', DCATAP.applicableLegislation) + self._add_extra_field(dataset_dict, dataset_ref, + 'hvdCategory', DCATAP.hvdCategory) self._add_version(dataset_dict, dataset_ref) if self._is_dataset_collection(dataset_dict): self._remove_predefined_collection_members() @@ -110,19 +162,57 @@ class ODSHDCATdeProfile(DCATdeProfile): rdflib.Literal(licenseAttributionByText)) ) - def _add_references(self, dataset_dict, dataset_ref): + def _add_extra_field(self, dataset_dict, dataset_ref, field_name, rdf_property): ''' - Adds reference (Musterdatenkatalog/Musterdatensatz) extra field to - dcat:references. + Adds extra fields from a dataset dictionary to a RDF graph. + + Parameters: + - dataset_dict: A dictionary containing dataset information. + - dataset_ref: The reference to the dataset in the RDF graph. + - field_name: The name of the field to extract from the dataset dictionary. + - rdf_property: The DCAT property to which the field value corresponds. + + This function extracts the value of the specified field from the dataset dictionary, + and adds it to the RDF graph with the given dataset reference and DCAT property. + If the field value is a list of values represented as a string enclosed in curly braces, + it splits the string and adds each value individually to the graph. + If the field value is a single value, it is added directly to the graph. + + Note: This function includes a workaround since CKAN's extras do not natively support + lists. It treats lists represented as strings enclosed in curly braces as a single string. ''' - sample_dataset_uri = helpers_odsh.odsh_extract_value_from_extras(dataset_dict.get('extras'), 'reference') - if sample_dataset_uri: + field_value_str = dataset_dict.get(field_name) + + if not field_value_str: + return + + try: + # Remove curly braces from the string + values_string = field_value_str.strip('{}') + + # Split the string by commas + field_values = values_string.split(',') + + # Trim any extra whitespace from each URL + field_values = [value.strip() for value in field_values] + + # Check if the field value is a list + if len(field_values) > 1: + for value in field_values: + self.g.add( + (dataset_ref, rdf_property, rdflib.URIRef(value)) + ) + else: + # Treat it as a single value + self.g.set( + (dataset_ref, rdf_property, rdflib.URIRef(field_values[0])) + ) + except (ValueError, SyntaxError): + # If parsing fails, treat the entire string as a single value self.g.set( - (dataset_ref, DCT.references, - rdflib.URIRef(sample_dataset_uri) - ) + (dataset_ref, rdf_property, rdflib.URIRef(field_value_str)) ) - + def _add_modified_and_issued(self, dataset_dict, dataset_ref): ''' Adds distributions last_modified and created values to @@ -149,26 +239,27 @@ class ODSHDCATdeProfile(DCATdeProfile): ''' Adds CKAN isReplacedBy extra field to dublin core isReplacedBy and sets version information. ''' - new_version = helpers_odsh.odsh_extract_value_from_extras(dataset_dict.get('extras'), 'is_replaced_by') + new_version = helpers_odsh.odsh_extract_value_from_extras( + dataset_dict.get('extras'), 'is_replaced_by') if new_version: self.g.set( (dataset_ref, DCTERMS.isReplacedBy, rdflib.URIRef(new_version) ) ) - - version_notes = helpers_odsh.odsh_extract_value_from_extras(dataset_dict.get('extras'), 'version_notes') + + version_notes = helpers_odsh.odsh_extract_value_from_extras( + dataset_dict.get('extras'), 'version_notes') if version_notes: self.g.set( (dataset_ref, ADMS.versionNotes, rdflib.Literal(version_notes) ) ) - + def _add_type(self, dataset_dict, dataset_ref): ''' - adds the type if there is a known mapping from ckan type to - dct:type + Adds the type if there is a known mapping from ckan type to dct:type ''' ckan_type = self._get_ckan_type(dataset_dict) dct_type = helpers_odsh.map_ckan_type_to_dct_type(ckan_type) diff --git a/ckanext/odsh/resources/applicable_legislations.json b/ckanext/odsh/resources/applicable_legislations.json new file mode 100644 index 0000000000000000000000000000000000000000..ae37037207e9e3bc72abc7607268ddafb5b8450a --- /dev/null +++ b/ckanext/odsh/resources/applicable_legislations.json @@ -0,0 +1,12 @@ +[ + { + "uri": "http://data.europa.eu/eli/reg_impl/2023/138/oj", + "title": "Durchführungsverordnung (EU) 2023/138 der Kommission vom 21. Dezember 2022 zur Festlegung bestimmter hochwertiger Datensätze und der Modalitäten ihrer Veröffentlichung und Weiterverwendung", + "short_title": "Durchführungsverordnung (EU) 2023/138" + }, + { + "uri": "http://data.europa.eu/eli/dir/2007/2/2019-06-26", + "title": "Richtlinie 2007/2/EG des Europäischen Parlaments und des Rates vom 14. März 2007 zur Schaffung einer Geodateninfrastruktur in der Europäischen Gemeinschaft (INSPIRE)", + "short_title": "Richtlinie 2007/2/EG" + } +] \ No newline at end of file diff --git a/ckanext/odsh/resources/hvd_categories.json b/ckanext/odsh/resources/hvd_categories.json new file mode 100644 index 0000000000000000000000000000000000000000..d57cf0505292f48b2556f82e2ee986bc864db719 --- /dev/null +++ b/ckanext/odsh/resources/hvd_categories.json @@ -0,0 +1,32 @@ +[ + { + "uri": "http://data.europa.eu/bna/c_ac64a52d", + "title": "Georaum", + "short_title": "Georaum" + }, + { + "uri": "http://data.europa.eu/bna/c_dd313021", + "title": "Erdbeobachtung und Umwelt", + "short_title": "Erdbeobachtung und Umwelt" + }, + { + "uri": "http://data.europa.eu/bna/c_164e0bf5", + "title": "Meteorologie", + "short_title": "Meteorologie" + }, + { + "uri": "http://data.europa.eu/bna/c_e1da4e07", + "title": "Statistik", + "short_title": "Statistik" + }, + { + "uri": "http://data.europa.eu/bna/c_a9135398", + "title": "Unternehmen und Eigentümerschaft von Unternehmen", + "short_title": "Unternehmen und Eigentümerschaft von Unternehmen" + }, + { + "uri": "http://data.europa.eu/bna/c_b79e35eb", + "title": "Mobilität", + "short_title": "Mobilität" + } +] \ No newline at end of file diff --git a/ckanext/odsh/templates/macros/form.html b/ckanext/odsh/templates/macros/form.html index 57a5c2a15e205d18abfc7442b36b63a8047a692c..610a9b69ef2ccdb00973f4c2c8f4f6f80b5ed1ed 100644 --- a/ckanext/odsh/templates/macros/form.html +++ b/ckanext/odsh/templates/macros/form.html @@ -163,31 +163,30 @@ is_required=false) %} {% endmacro %} -{# -Creates a select with an input field for autocomplete #} -{% macro select_autocomplete(name, id='', label='', options='', selected='', error='', classes=[], attrs={}, - is_required=false) %} -{% set classes = (classes|list) %} -{% do classes.append('control-select') %} +{# Creates a select with an input field for autocomplete #} +{% macro select_autocomplete(name, id='', label='', options='', selected='', error='', classes=[], attrs={}, + is_required=false, is_multiple=false) %} +{% set classes = classes|default([]) + ['control-select'] %} {%- set extra_html = caller() if caller -%} -{% call input_block(id or name, label or name, error, classes, extra_html=extra_html, is_required=is_required) -%} +{% call input_block(id or name, label or name, error, classes, extra_html=extra_html, is_required=is_required) %} <div class="row-fluid"> <div class="span6"> - <select id="{{ id or name }}" name="{{ name }}" {{ attributes(attrs) }} data-module="autocomplete"> - {% for option in options %} - <option value="{{ option.key }}" {% if option.key==selected %} selected {% endif %}>{{ option.text or - option.value }} </option> - {% endfor %} - </select> + <select id="{{ (id or name) }}" name="{{ name }}" + {{ attributes(attrs) }} data-module="autocomplete"{% if is_multiple %} multiple{% endif %}> + {% for option in options %} + <option value="{{ option.key or '' }}"{% if option.key in selected %} selected="selected"{% endif %}> + {{ option.text or option.value }} + </option> + {% endfor %} + </select> </div> <div class="span6 inline-error"> {% if error is iterable and error is not string %} - {{error|first}} + {{ error|first }} {% elif error is string %} - {{error}} + {{ error }} {% endif %} </div> </div> diff --git a/ckanext/odsh/templates/package/snippets/info.html b/ckanext/odsh/templates/package/snippets/info.html index 57385b3b5b51674aed6e457f37f585e362a39174..7c07d88ddbbb965c73f57f1625ae02395ee8299e 100644 --- a/ckanext/odsh/templates/package/snippets/info.html +++ b/ckanext/odsh/templates/package/snippets/info.html @@ -81,22 +81,66 @@ Example: {% endblock license %} {% block musterdatensatz %} - {% set musterdatensatzURI = h.odsh_extract_value_from_extras(pkg.extras,'reference') %} - {% if musterdatensatzURI %} + {% if pkg.reference %} {% set mdk=h.odsh_load_raw_mdk_sample_dataset() %} - {% set musterdatensatzName = mdk[musterdatensatzURI] %} + {% set musterdatensatzName = mdk[pkg.reference] %} <div class="musterdatensatz-detail info-detail"> - <div>{{ _('Musterdatensatz') }}</div> - <a href="/dataset?reference={{ musterdatensatzURI }}">{{ musterdatensatzName }}</a> + <div>{{ _('Sample Dataset') }}:</div> + <a href="/dataset?reference={{ pkg.reference }}">{{ musterdatensatzName }}</a> </div> {% endif %} {% endblock musterdatensatz %} + {% block applicableLegislation %} + {% if pkg.applicableLegislation %} + {% set applicable_legislation_urls = pkg.applicableLegislation.split(',') %} + <div class="applicableLegislation-detail info-detail"> + <div> + {% trans al_count=applicable_legislation_urls|length %} + Applicable Legislation: + {% pluralize %} + Applicable Legislation: + {% endtrans %} + </div> + <ul class="inline-list"> + {% for url in applicable_legislation_urls %} + {% set applicable_legislation = h.odsh_load_applicable_legislations(url.strip('{}')) %} + <li><a href="{{ applicable_legislation.uri }}">{{ applicable_legislation.short_title if applicable_legislation.short_title else applicable_legislation.title }}</a></li> + {% endfor %} + </ul> + </div> + {% endif %} + {% endblock applicableLegislation %} + + {% block hvdCategories %} + {% if pkg.hvdCategory %} + {% set hvd_urls = pkg.hvdCategory.split(',') %} + <div class="hvdCategories-detail info-detail"> + <div> + {% trans hvd_count=hvd_urls|length %} + HVD Category: + {% pluralize %} + HVD Categories: + {% endtrans %} + <a data-module="odsh_popover" data-module-trigger="custom" data-module-text="{{ _("<p>The EU Commission has published a list of particularly high-value datasets (HVD - High Value Datasets), which public authorities must make available free of charge and under an open license. Datasets are considered high-value if they "have a special potential for generating socio-economic benefits in connection with harmonized conditions for re-use". They are divided into six categories.</p><p><a href='https://www.govdata.de/web/guest/neues/-/blogs/hochwertige-datensatze'>More about HVD at the national Open Data Portal GovData.</a></p>") }}" title="{{ _('HVD Category') }}"> + <i class="fa fa-circle-info"></i> + </a> + </div> + <ul class="inline-list"> + {% for url in hvd_urls %} + {% set hvd = h.odsh_load_hvd_categories(url.strip('{}')) %} + <li>{{ hvd.short_title if hvd.short_title else hvd.title }}</li> + {% endfor %} + </ul> + </div> + {% endif %} + {% endblock hvdCategories %} + {% endblock package_info_inner %} </div> {% set map_text = h.odsh_get_spatial_text(pkg) %} <div class="spatial-detail info-detail"> - <div>{{ _('Spatial uri') }}:</div> + <div>{{ _('Spatial URI') }}:</div> {%set ext=map_text if map_text else '-'%} <p>{{ ext }}</p> </div> diff --git a/ckanext/odsh/templates/package/snippets/package_basic_fields.html b/ckanext/odsh/templates/package/snippets/package_basic_fields.html index 944dee9b905bb8c652ceb3742654b84d7e844fa2..5cf948b1bc1d175197930fdf909b03fdc16cb16f 100644 --- a/ckanext/odsh/templates/package/snippets/package_basic_fields.html +++ b/ckanext/odsh/templates/package/snippets/package_basic_fields.html @@ -84,8 +84,7 @@ dataset_is_draft)) %} <div class="span6"> <select id="field-organizations" name="owner_org" data-module="autocomplete"> {% if h.check_config_permission('create_unowned_dataset') %} - <option value="" {% if not selected_org and data.id %} selected="selected" {% endif %}>{{ _('No - organization') }}</option> + <option value="" {% if not selected_org and data.id %} selected="selected" {% endif %}>{{ _('No organization') }}</option> {% endif %} {% for organization in organizations_available %} {# get out first org from users list only if there is not an existing org #} @@ -336,14 +335,26 @@ dataset_is_draft)) %} </div> </div> </div> - -{% block scripts %} - {% asset 'ckanext-odsh/odsh_datepicker_script' %} - {% asset 'ckanext-odsh/odsh_form_script' %} -{% endblock scripts %} {# field reference #} {% set field = 'reference' %} {% set error_reference = h.odsh_extract_error(field, errors) %} -{% set value = h.odsh_extract_value_from_extras(data.extras,field) or '' %} -{{ form.select_autocomplete(field, label=_('Musterdatensatz'), selected=value, options=h.odsh_load_mdk_sample_dataset(), error=error_reference, is_required=False, classes=['control-full', 'field-reference'])}} +{% set value = data.get(field) or '' %} +{{ form.select_autocomplete(field, label=_('Sample Dataset'), selected=value, options=h.odsh_load_mdk_sample_dataset(), error=error_reference, is_required=False, classes=['control-full', 'field-reference'])}} + +{# field applicableLegislation #} +{% set field = 'applicableLegislation' %} +{% set error_reference = h.odsh_extract_error(field, errors) %} +{% set value = data.get(field) or '' %} +{{ form.select_autocomplete(field, label=_('Applicable Legislation'), selected=value, options=h.odsh_load_applicable_legislations(), error=error_reference, is_required=False, classes=['control-full', 'field-applicableLegislation'], is_multiple=True)}} + +{# field hvdCategory #} +{% set field = 'hvdCategory' %} +{% set error_reference = h.odsh_extract_error(field, errors) %} +{% set value = data.get(field) or '' %} +{{ form.select_autocomplete(field, label=_('HVD Category'), selected=value, options=h.odsh_load_hvd_categories(), error=error_reference, is_required=False, classes=['control-full', 'field-hvdCategory'], is_multiple=True)}} + +{% block scripts %} + {% asset 'ckanext-odsh/odsh_datepicker_script' %} + {% asset 'ckanext-odsh/odsh_form_script' %} +{% endblock scripts %} \ No newline at end of file diff --git a/ckanext/odsh/validation.py b/ckanext/odsh/validation.py index c850252966e648148639e25a7c671e7951550370..2131bfa4947c96af61e82c6b1f09cbe12fa7fe99 100644 --- a/ckanext/odsh/validation.py +++ b/ckanext/odsh/validation.py @@ -2,23 +2,15 @@ import logging import csv import re -import urllib.request -import urllib.error -import urllib.parse import json import ckan.logic as logic - -from itertools import count -from dateutil.parser import parse - import ckan.plugins.toolkit as toolkit import ckan.model as model +import pkg_resources +from dateutil.parser import parse from ckan.lib.navl.dictization_functions import Missing - from ckanext.odsh.helpers import get_package_dict from ckanext.odsh.helpers import odsh_resource_formats -import ckan.plugins.toolkit as tk -import pkg_resources _ = toolkit._ @@ -76,14 +68,14 @@ def validate_extras(key, data, errors, context): harvesting = ('ignore_auth' in context) and ( context['ignore_auth'] == True) owner_org = data[('owner_org',)] - lenient_with = tk.config.get('ckanext.odsh.lenient_with', '') + lenient_with = toolkit.config.get('ckanext.odsh.lenient_with', '') is_optional_temporal_start = toolkit.asbool( - tk.config.get('ckanext.odsh.is_optional_temporal_start', False) + toolkit.config.get('ckanext.odsh.is_optional_temporal_start', False) ) or (harvesting and (owner_org in lenient_with)) require_at_least_one_category = toolkit.asbool( - tk.config.get('ckanext.odsh.require_at_least_one_category', False) + toolkit.config.get('ckanext.odsh.require_at_least_one_category', False) ) validate_extra_groups( data=data, @@ -195,7 +187,7 @@ def known_spatial_uri(key, data, errors, context): _copy_spatial_uri_temp_to_extras(data) value = _extract_value(data, 'spatial_uri') require_spatial_uri = toolkit.asbool( - tk.config.get('ckanext.odsh.require_spatial_uri', False) + toolkit.config.get('ckanext.odsh.require_spatial_uri', False) ) error_message_spatial_uri_empty = 'spatial_uri: empty not allowed' @@ -212,7 +204,7 @@ def known_spatial_uri(key, data, errors, context): has_old_uri = old_uri != None and len(old_uri) > 0 if not poly: poly = pkg.extras.get('spatial', None) - if (not poly) and require_spatial_uri: + if not poly and require_spatial_uri: raise toolkit.Invalid(error_message_spatial_uri_empty) # if has_old_uri and require_spatial_uri: # raise toolkit.Invalid(error_message_spatial_uri_empty) @@ -224,8 +216,8 @@ def known_spatial_uri(key, data, errors, context): return extension_path = pkg_resources.resource_filename('ckanext.odsh', '') - mapping_path = tk.config.get('ckanext.odsh.spatial.mapping', - extension_path + '/resources/schleswig-holstein_geojson.csv') + mapping_path = toolkit.config.get('ckanext.odsh.spatial.mapping', + extension_path + '/resources/schleswig-holstein_geojson.csv') not_found = True spatial_text = str() @@ -257,15 +249,15 @@ def known_spatial_uri(key, data, errors, context): def _copy_spatial_uri_temp_to_extras(data): ''' - copy the field spatial_uri_temp or + Copy the field spatial_uri_temp or spatial_url_temp originating from the user interface to extras ''' - spatial_uri = data.get(('__extras',)).get('spatial_uri_temp') - if spatial_uri is None: - spatial_uri = data.get(('__extras',)).get('spatial_url_temp') - is_spatial_uri_in_extras = _extract_value(data, 'spatial_uri') is not None - if not is_spatial_uri_in_extras: + extras_data = data.get(('__extras',)) + spatial_uri = extras_data.get( + 'spatial_uri_temp') or extras_data.get('spatial_url_temp') + + if _extract_value(data, 'spatial_uri') is None: next_index = next_extra_index(data) data[('extras', next_index, 'key')] = 'spatial_uri' data[('extras', next_index, 'value')] = spatial_uri