Skip to content

Commit

Permalink
[#1081] resource_delete updates the package
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jul 3, 2013
1 parent fe79fed commit c972c1c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ckan/logic/action/delete.py
Expand Up @@ -69,6 +69,18 @@ def resource_delete(context, data_dict):

_check_access('resource_delete',context, data_dict)

package_id = entity.get_package_id()

pkg_dict = _get_action('package_show')(context, {'id': package_id})

if 'resources' in pkg_dict and id in pkg_dict['resources']:
pkg_dict['resources'].remove(id)
try:
pkg_dict = _get_action('package_update')(context, pkg_dict)
except ValidationError, e:
errors = e.error_dict['resources'][-1]
raise ValidationError(errors)

entity.delete()
model.repo.commit()

Expand Down

0 comments on commit c972c1c

Please sign in to comment.