def resource_id_validator(key, converted_data, errors, context): resource_id = converted_data.get(("resource_id",)) if (not resource_id) or (resource_id is df.missing): raise exceptions.InvalidResourceIDException(toolkit._("Missing resource_id argument")) resource_id = unicode(resource_id) try: core_validators.resource_id_exists(resource_id, context) except toolkit.Invalid: raise exceptions.InvalidResourceIDException(toolkit._("Invalid resource_id"))
def resource_id_validator(key, converted_data, errors, context): resource_id = converted_data.get(('resource_id', )) if (not resource_id) or (resource_id is df.missing): raise exceptions.InvalidResourceIDException( toolkit._("Missing resource_id argument")) resource_id = unicode(resource_id) try: core_validators.resource_id_exists(resource_id, context) except toolkit.Invalid: raise exceptions.InvalidResourceIDException( toolkit._("Invalid resource_id"))
def orgdashboards_get_resource_url(id): if not resource_id_exists(id, _get_ctx()): return None data = _get_action('resource_show', {}, {'id': id}) print data['url'] return data['url']
def orgportals_get_resource_url(id): if not resource_id_exists(id, _get_ctx()): return None data = toolkit.get_action('resource_show')({}, {'id': id}) return data['url']
def orgdashboards_get_resource_url(id): if not resource_id_exists(id, _get_ctx()): return None try: data = _get_action('resource_show', {}, {'id': id}) except l.NotFound: return '' return data['url'] + '/'
def test_resource_id_exists(self): resource = factories.Resource() ctx = self._make_context() v = validators.resource_id_exists(resource['id'], ctx) assert v == resource['id']
def test_resource_id_exists_empty(self): ctx = self._make_context() v = validators.resource_id_exists('', ctx)
def test_resource_id_exists(): resource = factories.Resource() v = validators.resource_id_exists(resource["id"], _make_context()) assert v == resource["id"]
def test_resource_id_exists_empty(): with pytest.raises(df.Invalid): validators.resource_id_exists("", _make_context())
def test_resource_id_exists(resource): v = validators.resource_id_exists(resource["id"], _make_context()) assert v == resource["id"]