diff --git a/ckanext/odsh/i18n/ckanext-odsh.pot b/ckanext/odsh/i18n/ckanext-odsh.pot index fdc2d33ba591d46e6351dab6bf3389e16dde46a2..cc5e4c2784281f4e216acec33e6ba979b84bec64 100644 --- a/ckanext/odsh/i18n/ckanext-odsh.pot +++ b/ckanext/odsh/i18n/ckanext-odsh.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ckanext-odsh 2.0.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-06-16 12:18+0200\n" +"POT-Creation-Date: 2023-07-03 13:39+0200\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,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.7.0\n" -#: ckanext/odsh/plugin.py:222 ckanext/odsh/plugin.py:231 ckanext/odsh/plugin.py:237 +#: ckanext/odsh/plugin.py:239 ckanext/odsh/plugin.py:248 ckanext/odsh/plugin.py:254 #: ckanext/odsh/templates/header.html:45 #: ckanext/odsh/templates/organization/index.html:3 #: ckanext/odsh/templates/organization/index.html:6 @@ -28,15 +28,15 @@ msgstr "" msgid "Organizations" msgstr "" -#: ckanext/odsh/plugin.py:223 ckanext/odsh/plugin.py:234 ckanext/odsh/plugin.py:240 +#: ckanext/odsh/plugin.py:240 ckanext/odsh/plugin.py:251 ckanext/odsh/plugin.py:257 msgid "Category" msgstr "" -#: ckanext/odsh/plugin.py:224 ckanext/odsh/plugin.py:232 ckanext/odsh/plugin.py:238 +#: ckanext/odsh/plugin.py:241 ckanext/odsh/plugin.py:249 ckanext/odsh/plugin.py:255 msgid "File format" msgstr "" -#: ckanext/odsh/plugin.py:225 ckanext/odsh/plugin.py:233 ckanext/odsh/plugin.py:239 +#: ckanext/odsh/plugin.py:242 ckanext/odsh/plugin.py:250 ckanext/odsh/plugin.py:256 #: ckanext/odsh/templates/package/resource_read.html:170 #: ckanext/odsh/templates/package/snippets/info.html:75 #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:91 @@ -44,14 +44,29 @@ msgstr "" msgid "License" msgstr "" -#: ckanext/odsh/plugin.py:227 +#: ckanext/odsh/plugin.py:244 msgid "Open-Data-Eigenschaften" msgstr "" -#: ckanext/odsh/validation.py:311 +#: ckanext/odsh/validation.py:308 msgid "Only formats on the list of the EU Publications Office are allowed." msgstr "" +#: ckanext/odsh/validation.py:324 +#, python-format +msgid "Tag \"%s\" length is less than minimum %s" +msgstr "" + +#: ckanext/odsh/validation.py:328 +#, python-format +msgid "Tag \"%s\" length is more than maximum %i" +msgstr "" + +#: ckanext/odsh/validation.py:338 +#, python-format +msgid "Invalid tag: \"%s\". Tags cannot contain line breaks." +msgstr "" + #: ckanext/odsh/fanstatic/moment.js:6 msgid "Weeks" msgstr "" @@ -104,8 +119,8 @@ msgstr "" #: ckanext/odsh/templates/package/base.html:7 #: ckanext/odsh/templates/package/base.html:17 #: ckanext/odsh/templates/package/base.html:22 -#: ckanext/odsh/templates/package/read.html:19 -#: ckanext/odsh/templates/package/read.html:24 +#: ckanext/odsh/templates/package/read.html:21 +#: ckanext/odsh/templates/package/read.html:26 #: ckanext/odsh/templates/package/search.html:10 msgid "Datasets" msgstr "" @@ -428,7 +443,7 @@ msgid "Are you sure you want to delete this data request?" msgstr "" #: ckanext/odsh/templates/datarequests/snippets/datarequest_form.html:30 -#: ckanext/odsh/templates/organization/snippets/organization_form.html:53 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:86 #: ckanext/odsh/templates/package/edit_view.html:19 #: ckanext/odsh/templates/package/snippets/package_form.html:33 #: ckanext/odsh/templates/package/snippets/resource_form.html:91 @@ -580,13 +595,18 @@ msgstr "" msgid "A little information about my organization..." msgstr "" -#: ckanext/odsh/templates/organization/snippets/organization_form.html:53 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:55 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:73 +msgid "Custom Field" +msgstr "" + +#: ckanext/odsh/templates/organization/snippets/organization_form.html:86 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:56 +#: ckanext/odsh/templates/organization/snippets/organization_form.html:89 msgid "Save Organization" msgstr "" @@ -598,7 +618,7 @@ msgstr "" #: ckanext/odsh/templates/package/base.html:23 #: ckanext/odsh/templates/package/edit_base.html:9 #: ckanext/odsh/templates/package/new_package_form.html:8 -#: ckanext/odsh/templates/package/read.html:25 +#: ckanext/odsh/templates/package/read.html:27 msgid "Create Dataset" msgstr "" @@ -673,47 +693,61 @@ msgstr "" msgid "Add" msgstr "" -#: ckanext/odsh/templates/package/read.html:37 +#: ckanext/odsh/templates/package/read.html:39 #: ckanext/odsh/templates/snippets/package_item.html:79 msgid "Draft" msgstr "" -#: ckanext/odsh/templates/package/read.html:40 +#: ckanext/odsh/templates/package/read.html:42 #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:275 #: ckanext/odsh/templates/snippets/organization.html:24 #: ckanext/odsh/templates/snippets/package_item.html:81 msgid "Deleted" msgstr "" -#: ckanext/odsh/templates/package/read.html:46 +#: ckanext/odsh/templates/package/read.html:48 msgid "Manage Dataset" msgstr "" -#: ckanext/odsh/templates/package/read.html:53 +#: ckanext/odsh/templates/package/read.html:55 #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:251 #: ckanext/odsh/templates/snippets/package_item.html:70 msgid "Private" msgstr "" -#: ckanext/odsh/templates/package/read.html:71 +#: ckanext/odsh/templates/package/read.html:73 msgid "Detailed information" msgstr "" -#: ckanext/odsh/templates/package/read.html:91 +#: ckanext/odsh/templates/package/read.html:77 +#, python-format +msgid "" +"Note: A <a href=\"%(latest_collection_member)s\">newer version</a> of this " +"dataset is available." +msgstr "" + +#: ckanext/odsh/templates/package/read.html:84 +#, python-format +msgid "" +"Note: This dataset has been replaced with a <a " +"href=\"%(is_replaced_by)s\">newer version</a>." +msgstr "" + +#: ckanext/odsh/templates/package/read.html:105 msgid "Add new resource" msgstr "" -#: ckanext/odsh/templates/package/read.html:108 +#: ckanext/odsh/templates/package/read.html:122 msgid "latest collection member" msgstr "" -#: ckanext/odsh/templates/package/read.html:113 -#: ckanext/odsh/templates/package/read.html:118 +#: ckanext/odsh/templates/package/read.html:127 +#: ckanext/odsh/templates/package/read.html:132 msgid "predecessor" msgstr "" -#: ckanext/odsh/templates/package/read.html:123 -#: ckanext/odsh/templates/package/read.html:128 +#: ckanext/odsh/templates/package/read.html:137 +#: ckanext/odsh/templates/package/read.html:142 msgid "successor" msgstr "" @@ -994,6 +1028,22 @@ msgstr "" msgid "Required information" msgstr "" +#: ckanext/odsh/templates/package/snippets/package_metadata_fields.html:5 +msgid "Versioning" +msgstr "" + +#: ckanext/odsh/templates/package/snippets/package_metadata_fields.html:9 +msgid "Is replaced by" +msgstr "" + +#: ckanext/odsh/templates/package/snippets/package_metadata_fields.html:9 +msgid "https://" +msgstr "" + +#: ckanext/odsh/templates/package/snippets/package_metadata_fields.html:14 +msgid "Version notes" +msgstr "" + #: ckanext/odsh/templates/package/snippets/resource_form.html:11 msgid "odsh Create Dataset" msgstr "" diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index 6bf68dc9f93013febed9691bc5448405092fffb9..39bbd2e85bb7f3f71e9e84eb5f9cb6ae33e3f56c 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -149,12 +149,13 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm for field in ['title', 'license_id']: schema.update({field: [toolkit.get_converter('not_empty')]}) - schema.update({ - 'reference': [ - toolkit.get_validator('ignore_missing'), - toolkit.get_converter('convert_to_extras') - ] - }) + for field in ['reference', 'is_replaced_by', 'version_notes']: + schema.update({ + field: [ + toolkit.get_validator('ignore_missing'), + toolkit.get_converter('convert_to_extras') + ] + }) for i, item in enumerate(schema['tag_string']): if item == tag_string_convert: @@ -191,7 +192,15 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm 'accessibility': [ toolkit.get_validator('ignore_missing'), toolkit.get_converter('convert_to_extras') - ] + ], + 'is_replaced_by': [ + toolkit.get_validator('ignore_missing'), + toolkit.get_converter('convert_to_extras') + ], + 'version_notes': [ + toolkit.get_validator('ignore_missing'), + toolkit.get_converter('convert_to_extras') + ], }) return schema @@ -213,6 +222,14 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm toolkit.get_converter('convert_from_extras'), toolkit.get_validator('ignore_missing') ], + 'is_replaced_by': [ + toolkit.get_validator('ignore_missing'), + toolkit.get_converter('convert_to_extras') + ], + 'version_notes': [ + toolkit.get_validator('ignore_missing'), + toolkit.get_converter('convert_to_extras') + ], }) return schema diff --git a/ckanext/odsh/profiles/odsh_dcat_de_profile.py b/ckanext/odsh/profiles/odsh_dcat_de_profile.py index 7e2026c69a5becb95103e1b4da5d35382f4d26e4..1f8063d34cf638f9505fc42baff34f4d634bd39a 100644 --- a/ckanext/odsh/profiles/odsh_dcat_de_profile.py +++ b/ckanext/odsh/profiles/odsh_dcat_de_profile.py @@ -1,4 +1,5 @@ import rdflib +from rdflib.namespace import DCTERMS from ckan.common import config import ckan.lib.helpers as helpers @@ -15,7 +16,7 @@ import ckanext.odsh.collection.helpers as helpers_collection 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/") - +ADMS = rdflib.namespace.Namespace("http://www.w3.org/ns/adms#") class ODSHDCATdeProfile(DCATdeProfile): @@ -80,6 +81,7 @@ class ODSHDCATdeProfile(DCATdeProfile): 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_version(dataset_dict, dataset_ref) if self._is_dataset_collection(dataset_dict): self._remove_predefined_collection_members() self._add_collection_members(dataset_dict, dataset_ref) @@ -143,6 +145,47 @@ class ODSHDCATdeProfile(DCATdeProfile): created, datatype="http://www.w3.org/2001/XMLSchema#dateTime")) ) + def _add_modified_and_issued(self, dataset_dict, dataset_ref): + ''' + Adds distributions last_modified and created values to + dcat:modified and dcat:issued. + ''' + for distribution in self.g.objects(dataset_ref, DCAT.distribution): + for resource_dict in dataset_dict.get('resources', []): + # Match distribution in graph and distribution in ckan-dict + if str(distribution) == resource_uri(resource_dict): + last_modified = resource_dict.get('last_modified', None) + if last_modified: + self.g.set( + (distribution, DCT.modified, rdflib.Literal( + last_modified, datatype="http://www.w3.org/2001/XMLSchema#dateTime")) + ) + created = resource_dict.get('created', None) + if created: + self.g.set( + (distribution, DCT.issued, rdflib.Literal( + created, datatype="http://www.w3.org/2001/XMLSchema#dateTime")) + ) + def _add_version(self, dataset_dict, dataset_ref): + ''' + 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') + 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') + 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 diff --git a/ckanext/odsh/templates/package/read.html b/ckanext/odsh/templates/package/read.html index fd2de74b9dcc510100b91d4c8793659efd97c25b..6b5f30c0b622d8544d07dfd4df498730c19661c5 100644 --- a/ckanext/odsh/templates/package/read.html +++ b/ckanext/odsh/templates/package/read.html @@ -8,6 +8,8 @@ {% set predecessor_url = collection['predecessor']['url'] if collection and 'predecessor' in collection else None %} {% set latest_collection_member = collection['persistent_link_last_member'] if collection else None %} {% set stars = h.odsh_openness_score_dataset_html(pkg) %} +{% set is_replaced_by = h.odsh_extract_value_from_extras(pkg.extras, 'is_replaced_by') %} +{% set version_notes = h.odsh_extract_value_from_extras(pkg.extras, 'version_notes') %} {% block breadcrumb_content %} {% if pkg %} @@ -72,10 +74,22 @@ </div> {% if successor_url %} <p class="hint-newer-version"> - Hinweis: Es ist eine <a href="{{ latest_collection_member }}"> - neuere Version</a> dieses Datensatzes verfügbar. + {% trans %} + Note: A <a href="{{ latest_collection_member }}">newer version</a> of this dataset is available. + {% endtrans %} </p> {% endif %} +{% if is_replaced_by %} +<div class="hint-newer-version"> + {% trans %} + Note: This dataset has been replaced with a <a href="{{ is_replaced_by }}">newer version</a>. + {% endtrans %} + {% if version_notes %} + <hr> + <small>{{ version_notes }}</small> + {% endif %} +</div> +{% endif %} {% if pkg.notes %} <div class="notes embedded-content"> {{ h.render_markdown(h.get_translated(pkg, 'notes')) }} @@ -144,4 +158,3 @@ </div> {% endblock primary_content_inner %} - diff --git a/ckanext/odsh/templates/package/snippets/package_metadata_fields.html b/ckanext/odsh/templates/package/snippets/package_metadata_fields.html index ad6eebc85ab4912e17c68a8a1a5e80a8b7a69974..a712b422b0bc61c862d23a72e0a551277b848213 100644 --- a/ckanext/odsh/templates/package/snippets/package_metadata_fields.html +++ b/ckanext/odsh/templates/package/snippets/package_metadata_fields.html @@ -1,2 +1,16 @@ +{% import 'macros/form.html' as form %} + {% block package_metadata_fields %} -{% endblock %} \ No newline at end of file + + <h3>{{ _("Versioning") }}</h3> + {% set field = 'is_replaced_by' %} + {% set error = h.odsh_extract_error(field, errors) %} + {% set value = h.odsh_extract_value_from_extras(data.extras,field) or '' %} + {{ form.input(field, label=_('Is replaced by'), placeholder=_('https://'), value=value, error=error, classes=['control-full']) }} + + {% set field = 'version_notes' %} + {% set error = h.odsh_extract_error(field, errors) %} + {% set value = h.odsh_extract_value_from_extras(data.extras,field) or '' %} + {{ form.textarea(field, label=_('Version notes'), value=value, error=error, classes=['control-full', 'span6']) }} + +{% endblock %}