Esempio n. 1
0
def get_survey_by_id(_id):
    survey = Survey()
    try:
        return jsonify(
            survey.getByUniqueIDAndID(stack.top.uniqueID, _id).serialize())
    except:
        raise SurveyNotFound(_id)
Esempio n. 2
0
def update_survey_by_id(_id):
    survey = Survey()
    consent = request.get_json(silent=True, force=True)
    
    try:
        survey.getByUniqueIDAndID(stack.top.uniqueID, _id).serialize()
    except:
        raise SurveyNotFound(_id)
    
    try:
        validate(consent, inputs.survey)
    except ValidationError as error:
        raise MethodNotAllowed(error.message)
    
    try:
        return jsonify(success=bool(survey.updateByUniqueIDAndID(stack.top.uniqueID, _id, 
                                                                 consent['survey'],
                                                                 consent['tags'],
                                                                 consent['ongoing'])))
    except ValueError as error:
        raise MethodNotAllowed(error.message)
    except db.BadValueException as error:
        raise MethodNotAllowed(error.message)
Esempio n. 3
0
def update_survey_by_id(_id):
    survey = Survey()
    consent = request.get_json(silent=True, force=True)

    try:
        survey.getByUniqueIDAndID(stack.top.uniqueID, _id).serialize()
    except:
        raise SurveyNotFound(_id)

    try:
        validate(consent, inputs.survey)
    except ValidationError as error:
        raise MethodNotAllowed(error.message)

    try:
        return jsonify(success=bool(
            survey.updateByUniqueIDAndID(stack.top.uniqueID, _id,
                                         consent['survey'], consent['tags'],
                                         consent['ongoing'])))
    except ValueError as error:
        raise MethodNotAllowed(error.message)
    except db.BadValueException as error:
        raise MethodNotAllowed(error.message)
Esempio n. 4
0
def get_survey_by_id(_id):
    survey = Survey()
    try:
        return jsonify(survey.getByUniqueIDAndID(stack.top.uniqueID, _id).serialize())
    except:
        raise SurveyNotFound(_id)