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

        :param profile: The profile 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({
            'appletId': folder['_id'],
            'parentType': 'profile'
        })
        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 profile %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')
Beispiel #3
0
    def remove(self, user, progress=None, **kwargs):
        """
        Delete a user, and all references to it in the database.

        :param user: The user document to delete.
        :type user: 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, user)
        if progress:
            progress.update(increment=1,
                            message='Deleted user ' + user['login'])