diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index 2da659adc6c..709064a088f 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -1324,8 +1324,11 @@ def resource_datapreview(self, id, resource_id): This could be an img tag where the image is loaded directly or an iframe that embeds a webpage, recline or a pdf preview. ''' - context = {'model': model, 'session': model.Session, - 'user': c.user or c.author} + context = { + 'model': model, + 'session': model.Session, + 'user': c.user or c.author + } try: c.resource = get_action('resource_show')(context, @@ -1341,7 +1344,7 @@ def resource_datapreview(self, id, resource_id): log.warn('Multiple previews are possible. {0}'.format(plugins_that_can_preview)) plugin = plugins_that_can_preview[0] - plugin.setup_template_variables(context, c) + plugin.setup_template_variables(context, {'resource': c.resource, 'package': c.package}) except NotFound: abort(404, _('Resource not found')) diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index c9db7cd90d2..57054e46ba5 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -1290,19 +1290,6 @@ def resource_preview(resource, pkg_id): directly = False url = '' - ''' - if resource.get('datastore_active') or format_lower in ['csv', 'xls', 'tsv']: - url = url_for(controller='package', action='resource_datapreview', - resource_id=resource['id'], preview_type='recline', id=pkg_id, qualified=True) - elif format_lower in PDF: - url = url_for(controller='package', action='resource_datapreview', - resource_id=resource['id'], preview_type='pdf', id=pkg_id, qualified=True) - elif format_lower == 'jsonp': - url = url_for(controller='package', action='resource_datapreview', - resource_id=resource['id'], preview_type='json', id=pkg_id, qualified=True) - elif format_lower in LOADABLE: - url = resource['url']''' - if _can_be_previewed(resource): url = url = url_for(controller='package', action='resource_datapreview', resource_id=resource['id'], id=pkg_id, qualified=True) diff --git a/ckan/plugins/interfaces.py b/ckan/plugins/interfaces.py index 7312dc3c905..c52ef3bdaa2 100644 --- a/ckan/plugins/interfaces.py +++ b/ckan/plugins/interfaces.py @@ -209,10 +209,9 @@ def requires_same_orign(self, resource): a different domain because of the same origin policy. ''' - def setup_template_variables(self, context, c): + def setup_template_variables(self, context, data_dict): ''' Add variables to c just prior to the template being rendered. - ``resource``, ``package`` and ``resource_json`` are already defined. ''' def preview_template(self, context):