'Delete the history -- this does not require a logged in user.'

@web.expose
def delete(self, trans, id, purge=False):

    try:
        current_history = self.history_manager.get_current(trans)
        history = self.history_manager.get_owned(self.decode_id(id), trans.user, current_history=current_history)
        if history.users_shared_with:
            raise exceptions.ObjectAttributeInvalidException('History    has    been    shared    with    others.    Unshare    it    before    deleting    it.')
        self.history_manager.delete(history, flush=(not purge))
        if purge:
            self.history_manager.purge(history)
        if (history == current_history):
            not_deleted_or_purged = [(model.History.deleted == false()), (model.History.purged == false())]
            most_recent_history = self.history_manager.most_recent(user=trans.user, filters=not_deleted_or_purged)
            if most_recent_history:
                self.history_manager.set_current(trans, most_recent_history)
            else:
                trans.get_or_create_default_history()
    except Exception as exc:
        return trans.show_error_message(exc)
    return trans.show_ok_message('History    deleted', refresh_frames=['history'])
