def test_delete(self):
        id_ = 1
        ann = Annotation(id=id_)
        ann.save()

        newann = Annotation.fetch(id_)
        newann.delete()

        noann = Annotation.fetch(id_)
        assert noann == None
    def test_delete(self):
        id_ = 1
        ann = Annotation(id=id_)
        ann.save()

        newann = Annotation.fetch(id_)
        newann.delete()

        noann = Annotation.fetch(id_)
        assert noann == None
Beispiel #3
0
def read_annotation(id):
    annotation = Annotation.fetch(id)
    if not annotation:
        return jsonify('Annotation not found!', status=404)

    failure = _check_action(annotation, 'read', current_user_id())
    if failure:
        return failure

    return jsonify(annotation)
Beispiel #4
0
def read_annotation(id):
    annotation = Annotation.fetch(id)
    if not annotation:
        return jsonify('Annotation not found!', status=404)

    failure = _check_action(annotation, 'read', current_user_id())
    if failure:
        return failure

    return jsonify(annotation)
    def test_basics(self):
        user = "******"
        ann = Annotation(text="Hello there", user=user)
        ann['ranges'] = []
        ann['ranges'].append({})
        ann['ranges'].append({})
        ann.save()

        ann = Annotation.fetch(ann.id)
        h.assert_equal(ann['text'], "Hello there")
        h.assert_equal(ann['user'], "alice")
        h.assert_equal(len(ann['ranges']), 2)
Beispiel #6
0
def delete_annotation(id):
    annotation = Annotation.fetch(id)

    if not annotation:
        return jsonify('Annotation not found. No delete performed.', status=404)

    failure = _check_action(annotation, 'delete', current_user_id())
    if failure:
        return failure

    annotation.delete()
    return None, 204
    def test_basics(self):
        user = "******"
        ann = Annotation(text="Hello there", user=user)
        ann['ranges'] = []
        ann['ranges'].append({})
        ann['ranges'].append({})
        ann.save()

        ann = Annotation.fetch(ann.id)
        h.assert_equal(ann['text'], "Hello there")
        h.assert_equal(ann['user'], "alice")
        h.assert_equal(len(ann['ranges']), 2)
Beispiel #8
0
def delete_annotation(id):
    annotation = Annotation.fetch(id)

    if not annotation:
        return jsonify('Annotation not found. No delete performed.',
                       status=404)

    failure = _check_action(annotation, 'delete', current_user_id())
    if failure:
        return failure

    annotation.delete()
    return None, 204
Beispiel #9
0
def update_annotation(id):
    annotation = Annotation.fetch(id)
    if not annotation:
        return jsonify('Annotation not found! No update performed.', status=404)

    failure = _check_action(annotation, 'update', current_user_id())
    if failure:
        return failure

    if request.json:
        updated = _filter_input(request.json)
        updated['id'] = id # use id from URL, regardless of what arrives in JSON payload

        if 'permissions' in updated and updated['permissions'] != annotation.get('permissions', {}):
            if not authz.authorize(annotation, 'admin', current_user_id()):
                return _failed_authz_response('permissions update')

        annotation.update(updated)
        annotation.save()

    return jsonify(annotation)
Beispiel #10
0
def update_annotation(id):
    annotation = Annotation.fetch(id)
    if not annotation:
        return jsonify('Annotation not found! No update performed.',
                       status=404)

    failure = _check_action(annotation, 'update', current_user_id())
    if failure:
        return failure

    if request.json:
        updated = _filter_input(request.json)
        updated[
            'id'] = id  # use id from URL, regardless of what arrives in JSON payload

        if 'permissions' in updated and updated[
                'permissions'] != annotation.get('permissions', {}):
            if not authz.authorize(annotation, 'admin', current_user_id()):
                return _failed_authz_response('permissions update')

        annotation.update(updated)
        annotation.save()

    return jsonify(annotation)
 def test_fetch(self):
     a = Annotation(foo='bar')
     a.save()
     b = Annotation.fetch(a.id)
     h.assert_equal(b['foo'], 'bar')
Beispiel #12
0
 def _get_annotation(self, id_):
     return Annotation.fetch(id_)
 def test_fetch(self):
     a = Annotation(foo='bar')
     a.save()
     b = Annotation.fetch(a.id)
     h.assert_equal(b['foo'], 'bar')