Skip to content
Snippets Groups Projects
Commit 8a5c84fa authored by Jesper Zedlitz's avatar Jesper Zedlitz
Browse files

Hinweis auf Musterdatensatz in den Metadaten

closes #40
parent 11a47c97
Branches
Tags
2 merge requests!21Merge dev to master,!18Hinweis auf Musterdatensatz in den Metadaten
......@@ -492,3 +492,32 @@ def odsh_load_mdk_sample_dataset():
raise
return result
def odsh_load_raw_mdk_sample_dataset():
'''
Load sample dataset (Musterkatalog/Musterdatensatz).
See https://bertelsmannstift.github.io/Musterdatenkatalog/def/musterdatensatz.rdf
and corresponding mapping in mdk_mapping.json file.
'''
path = os.path.abspath(os.path.dirname(__file__))
default_sample_data_file_path = os.path.join(path, "../../mdk_mapping.json")
sample_data_file_path = config.get(
'ckanext.odsh.sample_data_file_path', default_sample_data_file_path)
try:
with open(sample_data_file_path) as mapping_json:
result = json.loads(mapping_json.read(), object_pairs_hook=OrderedDict)
except IOError as err:
log.error(
'Could not load sample dataset mapping file from {}'
.format(sample_data_file_path)
)
raise
except ValueError as err:
log.error(
'Could not convert sample dataset mapping file from json. \nSample dataset mapping file: {}'
.format(sample_data_file_path)
)
raise
return result
......@@ -382,6 +382,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'tpsh_get_address_org':helpers_tpsh.get_address_org,
'tpsh_get_body_mail':helpers_tpsh.get_body_mail,
'odsh_load_mdk_sample_dataset': odsh_helpers.odsh_load_mdk_sample_dataset,
'odsh_load_raw_mdk_sample_dataset': odsh_helpers.odsh_load_raw_mdk_sample_dataset,
}
......
......@@ -81,6 +81,18 @@ Example:
</div>
{% endblock license %}
{% block musterdatensatz %}
{% set musterdatensatzURI = h.odsh_extract_value_from_extras(pkg.extras,'reference') %}
{% if musterdatensatzURI %}
{% set mdk=h.odsh_load_raw_mdk_sample_dataset() %}
{% set musterdatensatzName = mdk[musterdatensatzURI] %}
<div class="musterdatensatz-detail info-detail">
<div>Musterdatensatz:</div>
<a href="/dataset?reference={{ musterdatensatzURI }}">{{ musterdatensatzName }}</a>
</div>
{% endif %}
{% endblock musterdatensatz %}
{% endblock package_info_inner %}
</div>
{% set map_text = h.odsh_get_spatial_text(pkg) %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment