Exemple #1
0
def artifact_delete_req(artifact_id, user_id):
    """Deletes the artifact

    Parameters
    ----------
    artifact_id : int
        Artifact being acted on
    user_id : str
        The user requesting the action

    Returns
    -------
    dict
        Status of action, in the form {'status': status, 'message': msg}
        status: status of the action, either success or error
        message: Human readable message for status
    """
    pd = Artifact(int(artifact_id))
    access_error = check_access(pd.study.id, user_id)
    if access_error:
        return access_error
    try:
        Artifact.delete(int(artifact_id))
    except QiitaDBArtifactDeletionError as e:
        return {'status': 'error',
                'message': str(e)}
    return {'status': 'success',
            'message': ''}
    def delete_processed_data(self, study, user, callback):
        """Delete the selected processed data

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        pd_id = int(self.get_argument('processed_data_id'))

        try:
            Artifact.delete(pd_id)
            msg = ("Processed data %d has been deleted" % pd_id)
            msg_level = "success"
            pd_id = None
        except Exception as e:
            msg = ("Couldn't remove processed data %d: %s" %
                   (pd_id, str(e)))
            msg_level = "danger"

        callback((msg, msg_level, 'processed_data_tab', pd_id, None))
    def delete_raw_data(self, study, user, callback):
        """Delete the selected raw data

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        raw_data_id = int(self.get_argument('raw_data_id'))
        prep_template_id = int(self.get_argument('prep_template_id'))

        try:
            Artifact.delete(raw_data_id)
            msg = ("Raw data %d has been deleted from prep_template %d"
                   % (raw_data_id, prep_template_id))
            msg_level = "success"
        except Exception as e:
            msg = "Couldn't remove raw data %d: %s" % (raw_data_id, str(e))
            msg_level = "danger"

        callback((msg, msg_level, "prep_template_tab", prep_template_id, None))
    def delete_processed_data(self, study, user, callback):
        """Delete the selected processed data

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        pd_id = int(self.get_argument('processed_data_id'))

        try:
            Artifact.delete(pd_id)
            msg = ("Processed data %d has been deleted" % pd_id)
            msg_level = "success"
            pd_id = None
        except Exception as e:
            msg = ("Couldn't remove processed data %d: %s" % (pd_id, str(e)))
            msg_level = "danger"

        callback((msg, msg_level, 'processed_data_tab', pd_id, None))
    def delete_raw_data(self, study, user, callback):
        """Delete the selected raw data

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        raw_data_id = int(self.get_argument('raw_data_id'))
        prep_template_id = int(self.get_argument('prep_template_id'))

        try:
            Artifact.delete(raw_data_id)
            msg = ("Raw data %d has been deleted from prep_template %d" %
                   (raw_data_id, prep_template_id))
            msg_level = "success"
        except Exception as e:
            msg = "Couldn't remove raw data %d: %s" % (raw_data_id, str(e))
            msg_level = "danger"

        callback((msg, msg_level, "prep_template_tab", prep_template_id, None))
Exemple #6
0
def delete_artifact(artifact_id):
    """Deletes an artifact from the system

    Parameters
    ----------
    artifact_id : int
        The artifact to delete

    Returns
    -------
    dict of {str: str}
        A dict of the form {'status': str, 'message': str}
    """
    from qiita_db.artifact import Artifact

    status = 'success'
    msg = ''
    try:
        Artifact.delete(artifact_id)
    except Exception as e:
        status = 'danger'
        msg = str(e)

    return {'status': status, 'message': msg}