Skip to content

Commit

Permalink
Merge branch '1921-resource-show-via-package-show'
Browse files Browse the repository at this point in the history
  • Loading branch information
joetsoi committed Oct 7, 2014
2 parents 12f7480 + 3ca8fe5 commit 148d26e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ckan/logic/action/get.py
Expand Up @@ -1011,19 +1011,26 @@ def resource_show(context, data_dict):
id = _get_or_bust(data_dict, 'id')

resource = model.Resource.get(id)
context['resource'] = resource
resource_context = dict(context, resource=resource)

if not resource:
raise NotFound

_check_access('resource_show', context, data_dict)
resource_dict = model_dictize.resource_dictize(resource, context)
_check_access('resource_show', resource_context, data_dict)

_add_tracking_summary_to_resource_dict(resource_dict, model)
pkg_dict = logic.get_action('package_show')(
dict(context),
{'id': resource.resource_group.package.id})

for item in plugins.PluginImplementations(plugins.IResourceController):
resource_dict = item.before_show(resource_dict)
for resource_dict in pkg_dict['resources']:
if resource_dict['id'] == id:
break
else:
logging.error('Could not find resource ' + id)
raise NotFound(_('Resource was not found.'))

# original dictized version didn't include this field:
resource_dict.pop('revision_timestamp')
return resource_dict


Expand Down

0 comments on commit 148d26e

Please sign in to comment.