Exemplo n.º 1
0
 def _delete_annotations(self, user):
     annotations = self.request.db.query(Annotation).filter_by(
         userid=user.userid)
     for annotation in annotations:
         storage.delete_annotation(self.request.db, annotation.id)
         event = AnnotationEvent(self.request, annotation.id, "delete")
         self.request.notify_after_commit(event)
Exemplo n.º 2
0
 def _delete_annotations(self, user):
     annotations = self.request.db.query(Annotation) \
                                  .filter_by(userid=user.userid)
     for annotation in annotations:
         storage.delete_annotation(self.request.db, annotation.id)
         event = AnnotationEvent(self.request, annotation.id, 'delete')
         self.request.notify_after_commit(event)
Exemplo n.º 3
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()
Exemplo n.º 4
0
    def _delete_annotations(self, group):
        if group.pubid == "__world__":
            raise DeletePublicGroupError("Public group can not be deleted")

        annotations = self.request.db.query(Annotation).filter_by(
            groupid=group.pubid)
        for annotation in annotations:
            storage.delete_annotation(self.request.db, annotation.id)
            event = AnnotationEvent(self.request, annotation.id, "delete")
            self.request.notify_after_commit(event)
Exemplo n.º 5
0
    def _delete_annotations(self, group):
        if group.pubid == '__world__':
            raise DeletePublicGroupError('Public group can not be deleted')

        annotations = self.request.db.query(Annotation) \
                                     .filter_by(groupid=group.pubid)
        for annotation in annotations:
            storage.delete_annotation(self.request.db, annotation.id)
            event = AnnotationEvent(self.request, annotation.id, 'delete')
            self.request.notify_after_commit(event)
Exemplo n.º 6
0
Arquivo: api.py Projeto: rowhit/h
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}
Exemplo n.º 7
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")

    # TODO: Track down why we don't return an HTTP 204 like other DELETEs
    return {"id": context.annotation.id, "deleted": True}
Exemplo n.º 8
0
Arquivo: api.py Projeto: gnott/h
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}
Exemplo n.º 9
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 = []
    annotations = request.db.query(models.Annotation) \
                            .filter_by(userid=user.userid)
    for annotation in annotations:
        storage.delete_annotation(request.db, annotation.id)

    request.db.delete(user)
Exemplo n.º 10
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)
Exemplo n.º 11
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)
Exemplo n.º 12
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
Exemplo n.º 13
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()
Exemplo n.º 14
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