예제 #1
0
파일: survey.py 프로젝트: uzh/msregistry
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)
예제 #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)