Skip to content
Snippets Groups Projects
Commit 7017a820 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Added version notes and replaced by for datasets

parent ab984a4f
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ckanext-odsh 2.0.0\n" "Project-Id-Version: ckanext-odsh 2.0.0\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -17,7 +17,7 @@ msgstr "" ...@@ -17,7 +17,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.7.0\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/header.html:45
#: ckanext/odsh/templates/organization/index.html:3 #: ckanext/odsh/templates/organization/index.html:3
#: ckanext/odsh/templates/organization/index.html:6 #: ckanext/odsh/templates/organization/index.html:6
...@@ -28,15 +28,15 @@ msgstr "" ...@@ -28,15 +28,15 @@ msgstr ""
msgid "Organizations" msgid "Organizations"
msgstr "" 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" msgid "Category"
msgstr "" 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" msgid "File format"
msgstr "" 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/resource_read.html:170
#: ckanext/odsh/templates/package/snippets/info.html:75 #: ckanext/odsh/templates/package/snippets/info.html:75
#: ckanext/odsh/templates/package/snippets/package_basic_fields.html:91 #: ckanext/odsh/templates/package/snippets/package_basic_fields.html:91
...@@ -44,14 +44,29 @@ msgstr "" ...@@ -44,14 +44,29 @@ msgstr ""
msgid "License" msgid "License"
msgstr "" msgstr ""
#: ckanext/odsh/plugin.py:227 #: ckanext/odsh/plugin.py:244
msgid "Open-Data-Eigenschaften" msgid "Open-Data-Eigenschaften"
msgstr "" msgstr ""
#: ckanext/odsh/validation.py:311 #: ckanext/odsh/validation.py:308
msgid "Only formats on the list of the EU Publications Office are allowed." msgid "Only formats on the list of the EU Publications Office are allowed."
msgstr "" 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 #: ckanext/odsh/fanstatic/moment.js:6
msgid "Weeks" msgid "Weeks"
msgstr "" msgstr ""
...@@ -104,8 +119,8 @@ msgstr "" ...@@ -104,8 +119,8 @@ msgstr ""
#: ckanext/odsh/templates/package/base.html:7 #: ckanext/odsh/templates/package/base.html:7
#: ckanext/odsh/templates/package/base.html:17 #: ckanext/odsh/templates/package/base.html:17
#: ckanext/odsh/templates/package/base.html:22 #: ckanext/odsh/templates/package/base.html:22
#: ckanext/odsh/templates/package/read.html:19 #: ckanext/odsh/templates/package/read.html:21
#: ckanext/odsh/templates/package/read.html:24 #: ckanext/odsh/templates/package/read.html:26
#: ckanext/odsh/templates/package/search.html:10 #: ckanext/odsh/templates/package/search.html:10
msgid "Datasets" msgid "Datasets"
msgstr "" msgstr ""
...@@ -428,7 +443,7 @@ msgid "Are you sure you want to delete this data request?" ...@@ -428,7 +443,7 @@ msgid "Are you sure you want to delete this data request?"
msgstr "" msgstr ""
#: ckanext/odsh/templates/datarequests/snippets/datarequest_form.html:30 #: 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/edit_view.html:19
#: ckanext/odsh/templates/package/snippets/package_form.html:33 #: ckanext/odsh/templates/package/snippets/package_form.html:33
#: ckanext/odsh/templates/package/snippets/resource_form.html:91 #: ckanext/odsh/templates/package/snippets/resource_form.html:91
...@@ -580,13 +595,18 @@ msgstr "" ...@@ -580,13 +595,18 @@ msgstr ""
msgid "A little information about my organization..." msgid "A little information about my organization..."
msgstr "" 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 "" msgid ""
"Are you sure you want to delete this Organization? Note*: Deleting cannot be " "Are you sure you want to delete this Organization? Note*: Deleting cannot be "
"performed while public or private datasets belong to this organization." "performed while public or private datasets belong to this organization."
msgstr "" msgstr ""
#: ckanext/odsh/templates/organization/snippets/organization_form.html:56 #: ckanext/odsh/templates/organization/snippets/organization_form.html:89
msgid "Save Organization" msgid "Save Organization"
msgstr "" msgstr ""
...@@ -598,7 +618,7 @@ msgstr "" ...@@ -598,7 +618,7 @@ msgstr ""
#: ckanext/odsh/templates/package/base.html:23 #: ckanext/odsh/templates/package/base.html:23
#: ckanext/odsh/templates/package/edit_base.html:9 #: ckanext/odsh/templates/package/edit_base.html:9
#: ckanext/odsh/templates/package/new_package_form.html:8 #: 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" msgid "Create Dataset"
msgstr "" msgstr ""
...@@ -673,47 +693,61 @@ msgstr "" ...@@ -673,47 +693,61 @@ msgstr ""
msgid "Add" msgid "Add"
msgstr "" msgstr ""
#: ckanext/odsh/templates/package/read.html:37 #: ckanext/odsh/templates/package/read.html:39
#: ckanext/odsh/templates/snippets/package_item.html:79 #: ckanext/odsh/templates/snippets/package_item.html:79
msgid "Draft" msgid "Draft"
msgstr "" 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/package/snippets/package_basic_fields.html:275
#: ckanext/odsh/templates/snippets/organization.html:24 #: ckanext/odsh/templates/snippets/organization.html:24
#: ckanext/odsh/templates/snippets/package_item.html:81 #: ckanext/odsh/templates/snippets/package_item.html:81
msgid "Deleted" msgid "Deleted"
msgstr "" msgstr ""
#: ckanext/odsh/templates/package/read.html:46 #: ckanext/odsh/templates/package/read.html:48
msgid "Manage Dataset" msgid "Manage Dataset"
msgstr "" 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/package/snippets/package_basic_fields.html:251
#: ckanext/odsh/templates/snippets/package_item.html:70 #: ckanext/odsh/templates/snippets/package_item.html:70
msgid "Private" msgid "Private"
msgstr "" msgstr ""
#: ckanext/odsh/templates/package/read.html:71 #: ckanext/odsh/templates/package/read.html:73
msgid "Detailed information" msgid "Detailed information"
msgstr "" 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" msgid "Add new resource"
msgstr "" msgstr ""
#: ckanext/odsh/templates/package/read.html:108 #: ckanext/odsh/templates/package/read.html:122
msgid "latest collection member" msgid "latest collection member"
msgstr "" msgstr ""
#: ckanext/odsh/templates/package/read.html:113 #: ckanext/odsh/templates/package/read.html:127
#: ckanext/odsh/templates/package/read.html:118 #: ckanext/odsh/templates/package/read.html:132
msgid "predecessor" msgid "predecessor"
msgstr "" msgstr ""
#: ckanext/odsh/templates/package/read.html:123 #: ckanext/odsh/templates/package/read.html:137
#: ckanext/odsh/templates/package/read.html:128 #: ckanext/odsh/templates/package/read.html:142
msgid "successor" msgid "successor"
msgstr "" msgstr ""
...@@ -994,6 +1028,22 @@ msgstr "" ...@@ -994,6 +1028,22 @@ msgstr ""
msgid "Required information" msgid "Required information"
msgstr "" 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 #: ckanext/odsh/templates/package/snippets/resource_form.html:11
msgid "odsh Create Dataset" msgid "odsh Create Dataset"
msgstr "" msgstr ""
......
...@@ -149,8 +149,9 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm ...@@ -149,8 +149,9 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
for field in ['title', 'license_id']: for field in ['title', 'license_id']:
schema.update({field: [toolkit.get_converter('not_empty')]}) schema.update({field: [toolkit.get_converter('not_empty')]})
for field in ['reference', 'is_replaced_by', 'version_notes']:
schema.update({ schema.update({
'reference': [ field: [
toolkit.get_validator('ignore_missing'), toolkit.get_validator('ignore_missing'),
toolkit.get_converter('convert_to_extras') toolkit.get_converter('convert_to_extras')
] ]
...@@ -191,7 +192,15 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm ...@@ -191,7 +192,15 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'accessibility': [ 'accessibility': [
toolkit.get_validator('ignore_missing'), toolkit.get_validator('ignore_missing'),
toolkit.get_converter('convert_to_extras') 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 return schema
...@@ -213,6 +222,14 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm ...@@ -213,6 +222,14 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
toolkit.get_converter('convert_from_extras'), toolkit.get_converter('convert_from_extras'),
toolkit.get_validator('ignore_missing') 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 return schema
......
import rdflib import rdflib
from rdflib.namespace import DCTERMS
from ckan.common import config from ckan.common import config
import ckan.lib.helpers as helpers import ckan.lib.helpers as helpers
...@@ -15,7 +16,7 @@ import ckanext.odsh.collection.helpers as helpers_collection ...@@ -15,7 +16,7 @@ import ckanext.odsh.collection.helpers as helpers_collection
DCT = rdflib.namespace.Namespace("http://purl.org/dc/terms/") DCT = rdflib.namespace.Namespace("http://purl.org/dc/terms/")
DCAT = rdflib.namespace.Namespace("http://www.w3.org/ns/dcat#") 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/") 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): class ODSHDCATdeProfile(DCATdeProfile):
...@@ -80,6 +81,7 @@ class ODSHDCATdeProfile(DCATdeProfile): ...@@ -80,6 +81,7 @@ class ODSHDCATdeProfile(DCATdeProfile):
self._add_type(dataset_dict, dataset_ref) self._add_type(dataset_dict, dataset_ref)
self._add_modified_and_issued(dataset_dict, dataset_ref) self._add_modified_and_issued(dataset_dict, dataset_ref)
self._add_references(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): if self._is_dataset_collection(dataset_dict):
self._remove_predefined_collection_members() self._remove_predefined_collection_members()
self._add_collection_members(dataset_dict, dataset_ref) self._add_collection_members(dataset_dict, dataset_ref)
...@@ -143,6 +145,47 @@ class ODSHDCATdeProfile(DCATdeProfile): ...@@ -143,6 +145,47 @@ class ODSHDCATdeProfile(DCATdeProfile):
created, datatype="http://www.w3.org/2001/XMLSchema#dateTime")) 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): def _add_type(self, dataset_dict, dataset_ref):
''' '''
adds the type if there is a known mapping from ckan type to adds the type if there is a known mapping from ckan type to
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
{% set predecessor_url = collection['predecessor']['url'] if collection and 'predecessor' in collection else None %} {% 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 latest_collection_member = collection['persistent_link_last_member'] if collection else None %}
{% set stars = h.odsh_openness_score_dataset_html(pkg) %} {% 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 %} {% block breadcrumb_content %}
{% if pkg %} {% if pkg %}
...@@ -72,10 +74,22 @@ ...@@ -72,10 +74,22 @@
</div> </div>
{% if successor_url %} {% if successor_url %}
<p class="hint-newer-version"> <p class="hint-newer-version">
Hinweis: Es ist eine <a href="{{ latest_collection_member }}"> {% trans %}
neuere Version</a> dieses Datensatzes verfügbar. Note: A <a href="{{ latest_collection_member }}">newer version</a> of this dataset is available.
{% endtrans %}
</p> </p>
{% endif %} {% 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 %} {% if pkg.notes %}
<div class="notes embedded-content"> <div class="notes embedded-content">
{{ h.render_markdown(h.get_translated(pkg, 'notes')) }} {{ h.render_markdown(h.get_translated(pkg, 'notes')) }}
...@@ -144,4 +158,3 @@ ...@@ -144,4 +158,3 @@
</div> </div>
{% endblock primary_content_inner %} {% endblock primary_content_inner %}
{% import 'macros/form.html' as form %}
{% block package_metadata_fields %} {% block package_metadata_fields %}
<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 %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment