Skip to content
Snippets Groups Projects
Commit a29e4470 authored by Daniel Neuwirth's avatar Daniel Neuwirth
Browse files

finished the helper function in thumbnail/helpers

parent 7eb9a55e
Branches href-for-preview
Tags
No related merge requests found
from ckan.lib.helpers import resource_display_name
from ckan.lib.helpers import is_url, url_for
def thumbnail_namespace(filename):
return "/" + filename
def get_name_from_last_pdf_upload(package):
def get_download_link_for_thumbnail(package):
resources = package.get('resources')
for resource in resources[::-1]:
url_type =resource.get('url_type')
mimetype = resource.get('mimetype')
if url_type == 'upload' and mimetype == 'application/pdf':
return resource_display_name(resource)
package_id = resource.get('package_id')
resource_id = resource.get('id')
pre_resource_url = resource.get('url')
if is_url(pre_resource_url):
url_resource = pre_resource_url
else:
url_resource = url_for(controller='package',
action='resource_download',
id=package_id,
resource_id=resource_id,
filename=pre_resource_url,
qualified = True)
return url_resource
......@@ -54,5 +54,5 @@ class ThumbnailPlugin(plugins.SingletonPlugin):
return {
'thumbnail_namespace':thumbnail_helpers.thumbnail_namespace,
'thumbnail_get_name_from_last_pdf_upload':thumbnail_helpers.get_name_from_last_pdf_upload
'thumbail_get_download_link':thumbnail_helpers.get_download_link_for_thumbnail
}
......@@ -5,7 +5,7 @@
{% set successor_url = h.collection_get_successor(pkg) %}
{% set predecessor_url = h.collection_get_predecessor(pkg) %}
{% set latest_collection_member = h.collection_get_latest_member(pkg) %}
{% set thumbnail_name = h.thumbnail_get_name_from_last_pdf_upload(pkg) %}
{% set thumbnail_url = h.thumbail_get_download_link(pkg) %}
{% block breadcrumb_content %}
{% if pkg %}
......@@ -80,7 +80,8 @@
<section id="dataset-preview">
<h3>{{ _('Preview') }}:</h3>
<div class="container-preview-large">
<a href="#">
<a href="{{ thumbnail_url }}">
<img src= "{{ picture }}" alt= "Vorschau"/>
</a>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment