예제 #1
0
def delete_survey_by_id(_id):
    """
    Delete existing survey by _id
    """
    survey = Survey()
    old = 'NO OLD SURVEY FOUND!'
    try:
        old = survey.getByID(_id).serialize()
        return jsonify(success=bool(survey.deleteByUniqueID(_id)))
    except ValueError as error:
        raise MethodNotAllowed(error.message)
    except BadValueException as error:
        raise MethodNotAllowed(error.message)
    except SurveyNotFound as error:
        raise SurveyNotFound(_id)
    finally:
        add_to_audit_log(
            'delete_survey_by_id',
            survey_id=_id,
            old=old,
        )