Skip to content
Snippets Groups Projects
Commit e2f9e84f authored by Benjamin Becker's avatar Benjamin Becker
Browse files

adds filter for languages

parent 6c5fbfad
No related branches found
No related tags found
No related merge requests found
# encoding: utf-8
import csv
import datetime
import logging
from string import lower
import json
import re
import urllib2
......@@ -13,15 +11,15 @@ import os
from ckan.common import config
import ckan.lib.helpers as helpers
import ckan.logic.action.create as create
import ckan.model as model
import ckan.plugins.toolkit as toolkit
import ckanext.odsh.helpers as odsh_helpers
log = logging.getLogger(__name__)
CKAN_TYPES = {'http://dcat-ap.de/def/datasetTypes/collection': 'collection'}
......@@ -142,6 +140,10 @@ def _get_language_id(pkg_dict):
language_id_cleaned = re.sub('[\[\]\"]', '', language_id)
return language_id_cleaned
def get_language_human_readable(language_id):
LANGUAGE_MAPPING = load_language_mapping()
return LANGUAGE_MAPPING.get(language_id)
def get_spatial_for_selection():
mapping_path = config.get('ckanext.odsh.spatial.mapping')
try:
......
......@@ -177,6 +177,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'groups': _('Kategorie'),
'subject_text': _('Informationsgegenstand'),
'tags': _('Tags'),
'language': _('Language'),
})
def group_facets(self, facets_dict, group_type, package_type):
......@@ -385,6 +386,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'tpsh_get_body_mail':helpers_tpsh.get_body_mail,
'tpsh_git_commit_hash': helpers_tpsh.git_commit_hash,
'tpsh_is_informationsgegenstand_gerichtsurteil_selected': helpers_tpsh.is_informationsgegenstand_gerichtsurteil_selected,
'tpsh_get_language_human_readable': helpers_tpsh.get_language_human_readable,
}
......
......@@ -44,9 +44,15 @@
{% endif %}
<label class="odsh-visible-label" for="check-{{ title.lower() }}-{{ loop.index }}">
{% if name=='language' %}
<a href="{{ href }}" title="{{ label if label != label_truncated else '' }}">
<span id="description-{{ title.lower() }}-{{ loop.index }}">{{ h.tpsh_get_language_human_readable(label) }}</span>
</a>
{% else %}
<a href="{{ href }}" title="{{ label if label != label_truncated else '' }}">
<span id="description-{{ title.lower() }}-{{ loop.index }}">{{ label }}</span>
</a>
{% endif %}
</label>
</div>
<div class="facet_count">
......
......@@ -77,8 +77,10 @@
{% set search_facets_items = facets.search.get(field)['items'] %}
{% for value in facets.fields[field] %}
<span class="filtered pill">
{% if(field=='openness')%}
{% if field == 'openness' %}
{{_(value)}}
{%- elif field == 'language' -%}
{{ h.tpsh_get_language_human_readable(value) }}
{%- else -%}
{%- if facets.translated_fields and facets.translated_fields.has_key((field,value)) -%}
{{ facets.translated_fields[(field,value)] }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment