diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index 8bea383b06aaa2b321156502c33e9df9d14dfedf..c6ec48b7f980dcbda2033274ed0e1dc9ae79082d 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -16,6 +16,7 @@ import csv import urllib2 from ckan.common import request import pdb +from urlparse import urlsplit, urlunsplit get_action = logic.get_action log = logging.getLogger(__name__) @@ -235,3 +236,11 @@ def spatial_extends_available(): spatial_text = row[1] result.append(spatial_text.decode('UTF-8')) return result + +def odsh_public_resource_url(res): + home = config.get('ckanext.odsh.public_url') + if res.get('url_type',None) == 'upload' and 'url' in res: + f = urlsplit(res['url']) + return urlunsplit((0, 0, f[2], f[3], f[4])) + else: + return res['url'] diff --git a/ckanext/odsh/logic/action.py b/ckanext/odsh/logic/action.py index 0bcc67272dfcf90442067350787fd3db0d8a7c5e..b6a0268d37d99268b831f41311827ea41cb02bf9 100644 --- a/ckanext/odsh/logic/action.py +++ b/ckanext/odsh/logic/action.py @@ -7,12 +7,20 @@ from ckan.lib.search.common import ( make_connection, SearchError, SearchQueryError ) import pysolr +import datetime log = logging.getLogger(__name__) def odsh_package_create(context, data_dict): munge_increment_name(data_dict) + issued = False + for extra in data_dict.get('extras'): + if extra['key'] == 'issued': + issued = True + break + if not issued: + data_dict['extras'].append({'key': 'issued', 'value': datetime.datetime.utcnow().isoformat()}) return package_create(context, data_dict) diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index a6382b31ea41a8996e4f739fd212905023a2f4d6..2979586841ce211007a9b0cdd4b45556c9ccf6a7 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -290,7 +290,11 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm 'odsh_tracking_url': odsh_helpers.odsh_tracking_url, 'odsh_has_more_facets': odsh_helpers.odsh_has_more_facets, 'odsh_public_url': odsh_helpers.odsh_public_url, +<<<<<<< HEAD 'odsh_spatial_extends_available': odsh_helpers.spatial_extends_available +======= + 'odsh_public_resource_url': odsh_helpers.odsh_public_resource_url +>>>>>>> sprint11 } def after_map(self, map): diff --git a/ckanext/odsh/templates/package/snippets/resource_item.html b/ckanext/odsh/templates/package/snippets/resource_item.html index 20daf85e2a72769f395c2f7d2f8d7f2719716532..cf63b5a7ba30932a882c494c31c6b0c7c29d556b 100644 --- a/ckanext/odsh/templates/package/snippets/resource_item.html +++ b/ckanext/odsh/templates/package/snippets/resource_item.html @@ -1,8 +1,8 @@ {% set url_action = 'resource_edit' if url_is_edit and can_edit else 'resource_read' %} {% set url = h.url_for(controller='package', action=url_action, id=pkg.name, resource_id=res.id) %} -{% set download = res.url or url %} -{% set res_details = h.odsh_get_resource_details(res.id) %} +{# hack for correcting slave url if resource was uploaded #} +{% set download = h.odsh_public_resource_url(res) or ulr%} <li class="resource-item" data-id="{{ res.id }}">