Esempio n. 1
0
    def test_it_deletes_the_annotation(self, db_session, factories):
        ann_1, ann_2 = (factories.Annotation(), factories.Annotation())

        storage.delete_annotation(db_session, ann_1.id)
        db_session.commit()

        assert db_session.query(Annotation).get(ann_1.id) is None
        assert db_session.query(Annotation).get(ann_2.id) == ann_2
Esempio n. 2
0
    def test_it_deletes_the_annotation(self, db_session, factories):
        ann_1, ann_2 = (factories.Annotation(), factories.Annotation())

        storage.delete_annotation(db_session, ann_1.id)
        db_session.commit()

        assert db_session.query(Annotation).get(ann_1.id) is None
        assert db_session.query(Annotation).get(ann_2.id) == ann_2
Esempio n. 3
0
    def test_it_deletes_the_annotation(self, db_session):
        ann_1 = Annotation(userid='luke')
        ann_2 = Annotation(userid='leia')
        db_session.add_all([ann_1, ann_2])
        db_session.flush()

        storage.delete_annotation(db_session, ann_1.id)
        db_session.commit()

        assert db_session.query(Annotation).get(ann_1.id) is None
        assert db_session.query(Annotation).get(ann_2.id) == ann_2
Esempio n. 4
0
    def test_it_deletes_the_annotation(self, db_session):
        ann_1 = Annotation(userid='luke')
        ann_2 = Annotation(userid='leia')
        db_session.add_all([ann_1, ann_2])
        db_session.flush()

        storage.delete_annotation(db_session, ann_1.id)
        db_session.commit()

        assert db_session.query(Annotation).get(ann_1.id) is None
        assert db_session.query(Annotation).get(ann_2.id) == ann_2
Esempio n. 5
0
def delete(annotation, request):
    """Delete the specified annotation."""
    storage.delete_annotation(request.db, annotation.id)

    # N.B. We publish the original model (including all the original annotation
    # fields) so that queue subscribers have context needed to decide how to
    # process the delete event. For example, the streamer needs to know the
    # target URLs of the deleted annotation in order to know which clients to
    # forward the delete event to.
    _publish_annotation_event(request, annotation, 'delete')

    return {'id': annotation.id, 'deleted': True}
Esempio n. 6
0
def delete(context, request):
    """Delete the specified annotation."""
    storage.delete_annotation(request.db, context.annotation.id)

    # N.B. We publish the original model (including all the original annotation
    # fields) so that queue subscribers have context needed to decide how to
    # process the delete event. For example, the streamer needs to know the
    # target URLs of the deleted annotation in order to know which clients to
    # forward the delete event to.
    _publish_annotation_event(
        request,
        context.annotation,
        'delete')

    return {'id': context.annotation.id, 'deleted': True}
Esempio n. 7
0
def delete_user(request, user):
    """
    Deletes a user with all their group memberships and annotations.

    Raises UserDeletionError when deletion fails with the appropriate error
    message.
    """

    if models.Group.created_by(request.db, user).count() > 0:
        raise UserDeletionError('Cannot delete user who is a group creator.')

    user.groups = []

    query = _all_user_annotations_query(request, user)
    annotations = es_helpers.scan(client=request.es.conn, query={'query': query})
    for annotation in annotations:
        storage.delete_annotation(request.db, annotation['_id'])

    request.db.delete(user)
Esempio n. 8
0
    def test_it_touches_the_updated_field(self, db_session, factories, datetime):
        ann = factories.Annotation()

        storage.delete_annotation(db_session, ann.id)

        assert ann.updated == datetime.utcnow()
Esempio n. 9
0
    def test_it_marks_the_annotation_as_deleted(self, db_session, factories):
        ann = factories.Annotation()

        storage.delete_annotation(db_session, ann.id)

        assert ann.deleted
Esempio n. 10
0
    def test_it_touches_the_updated_field(self, db_session, factories, datetime):
        ann = factories.Annotation()

        storage.delete_annotation(db_session, ann.id)

        assert ann.updated == datetime.utcnow()
Esempio n. 11
0
    def test_it_marks_the_annotation_as_deleted(self, db_session, factories):
        ann = factories.Annotation()

        storage.delete_annotation(db_session, ann.id)

        assert ann.deleted