Skip to content

Commit

Permalink
[#1251] Bug fix: resource_view_list returns [] if
Browse files Browse the repository at this point in the history
no views, not NotFound
  • Loading branch information
johnglover committed Nov 4, 2013
1 parent a9d2c1e commit 29a7759
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions ckan/controllers/package.py
Expand Up @@ -381,12 +381,9 @@ def read(self, id, format='html'):

# can the resources be previewed?
for resource in c.pkg_dict['resources']:
try:
get_action('resource_view_list')(
context, {'id': resource['id']})
resource['has_views'] = True
except NotFound:
resource['has_views'] = False
resource_views = get_action('resource_view_list')(
context, {'id': resource['id']})
resource['has_views'] = len(resource_views) > 0

self._setup_template_variables(context, {'id': id},
package_type=package_type)
Expand Down Expand Up @@ -1198,14 +1195,10 @@ def resource_read(self, id, resource_id):

c.related_count = c.pkg.related_count

vars = {}
try:
vars['resource_views'] = get_action('resource_view_list')(
context, {'id': resource_id})
c.resource['has_views'] = True
except NotFound:
vars['resource_views'] = []
c.resource['has_views'] = False
resource_views = get_action('resource_view_list')(
context, {'id': resource_id})
vars = {'resource_views': resource_views}
c.resource['has_views'] = len(resource_views) > 0

return render('package/resource_read.html', extra_vars=vars)

Expand Down

0 comments on commit 29a7759

Please sign in to comment.