Commit 5ff7fdeb authored by Marko Kuder's avatar Marko Kuder
Browse files

rename 'OPSI API' format to 'Prog. vmesnik', add to search list results

parent 409e659f
......@@ -242,6 +242,12 @@ def is_datastore_compatible(resource):
return ((resource.get('qa') and resource.get('qa')['format'] and resource.get('qa')['format'].lower() in supported_formats) or
(resource.get('format') and resource.get('format').lower() in supported_formats))
def has_datastore_resource(package):
for resource in package.get('resources'):
if resource.get('datastore_active', False):
return True
return False
def is_geo_preview_compatible(resource):
'''we are not overly strict about this - if either qa detects a supported format or a user
insists that it is a supported format, we accept it as such'''
......@@ -2358,9 +2364,9 @@ def search_facet_tooltip(key,value):
]
return captions[stars]
if key=='res_format':
if value == 'OPSI API':
return u'Zbirke vsebujejo podatke, po katerih je mogoče ' \
u'poizvedovati z OPSI API in jih prenesti v različnih formatih.'
if value == 'Prog. vmesnik':
return u'Zbirke vsebujejo podatke, po katerih je mogoče poizvedovati v ' \
u'programskem vmesniku OPSI in jih prenesti v različnih formatih.'
elif value:
return u'Zbirke vsebujejo datoteke v formatu ' + value
......
......@@ -307,16 +307,16 @@ class SearchIndexing(object):
@classmethod
def add_datastore_active(cls, pkg_dict):
# Add information if package has data in datastore, by adding the OPSI API format
# Add information if package has data in datastore with an artificial format
for r in pkg_dict.get('resources', []):
if r.get('datastore_active', False):
pkg_dict['res_format'] = pkg_dict.get('res_format', []).append('OPSI API')
pkg_dict['res_format'] = pkg_dict.get('res_format', []).append('Prog. vmesnik')
return
try:
data_dict = json.loads(pkg_dict.get('data_dict',''))
for r in data_dict.get('resources', []):
if r.get('datastore_active', False):
pkg_dict.setdefault('res_format', []).append('OPSI API')
pkg_dict.setdefault('res_format', []).append('Prog. vmesnik')
return
except ValueError: # includes JSONDecodeError
log.warning('data_dict of package could not be decoded, datastore_active flag may not be set correctly')
......
......@@ -240,6 +240,10 @@
{% for format in h.formats_for_package(package) %}
{{format_box(format.lower())}}
{% endfor %}
{% if h.has_datastore_resource(package) %}
{{format_box('Prog. vmesnik')}}
{% endif %}
<div class="clearfix clearfix-ie7"> &nbsp;</div>
</div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment