Skip to content

Instantly share code, notes, and snippets.

@dwcaraway
Created December 11, 2013 18:45
Show Gist options
  • Save dwcaraway/7916102 to your computer and use it in GitHub Desktop.
Save dwcaraway/7916102 to your computer and use it in GitHub Desktop.
https://github.com/GSA/enterprise-data-inventory/issues/34: Problem of resource being required for all datasets
if not data_provided and save_action != "go-dataset-complete":
if save_action == 'go-dataset':
# go to final stage of adddataset
redirect(h.url_for(controller='package',
action='edit', id=id))
# see if we have added any resources
try:
data_dict = get_action('package_show')(context, {'id': id})
except NotAuthorized:
abort(401, _('Unauthorized to update dataset'))
except NotFound:
abort(404,
_('The dataset {id} could not be found.').format(id=id))
if not len(data_dict['resources']):
# no data so keep on page
msg = _('You must add at least one data resource')
# On new templates do not use flash message
if g.legacy_templates:
h.flash_error(msg)
redirect(h.url_for(controller='package',
action='new_resource', id=id))
else:
errors = {}
error_summary = {_('Error'): msg}
return self.new_resource(id, data, errors, error_summary)
# we have a resource so let them add metadata
redirect(h.url_for(controller='package',
action='new_metadata', id=id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment