Esempio n. 1
0
    def remove(self, folder, progress=None, **kwargs):
        """
        Delete a folder recursively.

        :param folder: The folder document to delete.
        :type folder: dict
        :param progress: A progress context to record progress on.
        :type progress: girderformindlogger.utility.progress.ProgressContext or None.
        """
        # Remove the contents underneath this folder recursively.
        from girderformindlogger.models.upload import Upload

        self.clean(folder, progress, **kwargs)

        # Delete pending uploads into this folder
        uploadModel = Upload()
        uploads = uploadModel.find({
            'parentId': folder['_id'],
            'parentType': 'folder'
        })
        for upload in uploads:
            uploadModel.remove(upload, progress=progress, **kwargs)
        uploads.close()

        # Delete this folder
        AccessControlledModel.remove(self, folder, progress=progress, **kwargs)
        if progress:
            progress.update(increment=1, message='Deleted folder %s' %
                            folder['name'])
    def remove(self, invitation, progress=None, **kwargs):
        """
        Delete an invitation.

        :param invitation: The invitation document to delete.
        :type invitation: dict
        """
        # Delete this invitation
        AccessControlledModel.remove(self,
                                     invitation,
                                     progress=progress,
                                     **kwargs)
        if progress:
            progress.update(increment=1, message='Deleted invitation')
Esempio n. 3
0
    def remove(self, group, **kwargs):
        """
        Delete a group, and all references to it in the database.

        :param group: The group document to delete.
        :type group: dict
        """
        # Remove references to this group from user group membership lists
        from girderformindlogger.models.user import User
        User().update({'groups': group['_id']},
                      {'$pull': {
                          'groups': group['_id']
                      }})

        # Finally, delete the document itself
        AccessControlledModel.remove(self, group)
Esempio n. 4
0
    def remove(self, protoUser, progress=None, **kwargs):
        """
        Delete a protoUser, and all references to it in the database.

        :param protoUser: The protoUser document to delete.
        :type protoUser: dict
        :param progress: A progress context to record progress on.
        :type progress: girderformindlogger.utility.progress.ProgressContext or None.
        """
        from girderformindlogger.models.folder import Folder
        from girderformindlogger.models.group import Group
        from girderformindlogger.models.token import Token

        # Delete all authentication tokens owned by this user
        # Token().removeWithQuery({'userId': user['_id']})

        # Delete all pending group invites for this user
        # Group().update(
        #     {'requests': user['_id']},
        #     {'$pull': {'requests': user['_id']}}
        # )

        # Delete all of the folders under this user
        # folderModel = Folder()
        # folders = folderModel.find({
        #     'parentId': user['_id'],
        #     'parentCollection': 'user'
        # })
        # for folder in folders:
        #     folderModel.remove(folder, progress=progress, **kwargs)

        # Finally, delete the user document itself
        AccessControlledModel.remove(self, protoUser)
        if progress:
            progress.update(
                increment=1,
                message='Deleted protoUser ' + protoUser['email']
            )
Esempio n. 5
0
    def remove(self, collection, progress=None, **kwargs):
        """
        Delete a collection recursively.

        :param collection: The collection document to delete.
        :type collection: dict
        :param progress: A progress context to record progress on.
        :type progress: girderformindlogger.utility.progress.ProgressContext or None.
        """
        from girderformindlogger.models.folder import Folder

        folderModel = Folder()
        folders = folderModel.find({
            'parentId': collection['_id'],
            'parentCollection': 'collection'
        })
        for folder in folders:
            folderModel.remove(folder, progress=progress, **kwargs)

        # Delete this collection
        AccessControlledModel.remove(self, collection)
        if progress:
            progress.update(increment=1,
                            message='Deleted collection ' + collection['name'])