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"))
Beispiel #3
0
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']
Beispiel #4
0
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']
Beispiel #5
0
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'] + '/'
Beispiel #6
0
 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']
Beispiel #7
0
 def test_resource_id_exists_empty(self):
     ctx = self._make_context()
     v = validators.resource_id_exists('', ctx)
Beispiel #8
0
 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']
Beispiel #9
0
 def test_resource_id_exists_empty(self):
     ctx = self._make_context()
     v = validators.resource_id_exists('', ctx)
Beispiel #10
0
def test_resource_id_exists():
    resource = factories.Resource()
    v = validators.resource_id_exists(resource["id"], _make_context())
    assert v == resource["id"]
Beispiel #11
0
def test_resource_id_exists_empty():
    with pytest.raises(df.Invalid):
        validators.resource_id_exists("", _make_context())
Beispiel #12
0
def test_resource_id_exists(resource):
    v = validators.resource_id_exists(resource["id"], _make_context())
    assert v == resource["id"]