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)
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)
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()
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)
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)
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}
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}
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}
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)
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)
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)
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
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()
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