api/survey_api.py
def update_survey(survey_id=None):
    """
    Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects
    content, weekly_timings, absolute_timings, relative_timings, and settings in the request body
    """
    try:
        survey = Survey.objects.get(pk=survey_id)
    except Survey.DoesNotExist:
        return abort(404)
    # BUG: There is an unknown situation where the frontend sends a string requiring an extra
    # deserialization operation, causing 'content' to be a string containing a json string
    # containing a json list, instead of just a string containing a json list.
    json_content = request.values.get('content')
    content = None

    # Weird corner case: the Image survey does not have any content associated with it. Therefore,
    # when you try and make a post request to save any settings you have, it gives you a 500 error
    # because the request.values.get('content') returns a json item of "". The recursive_survey_content_json_decode
    # function is not able to decode 2 double quotations marks. This is why retrieving the json_content from the post
    # request is put outside of the decode statement. HOWEVER, evaluating json_content == "" returns false, since the
    # LITERAL value of the json_content is 2 quotation marks, NOT an empty string. Thus, we need to compare the
    # json_content to a string of 2 quotation marks (ie. '""')
    if json_content != '""':
        content = recursive_survey_content_json_decode(json_content)
        content = make_slider_min_max_values_strings(content)
    if survey.survey_type == Survey.TRACKING_SURVEY:
        errors = do_validate_survey(content)
        if len(errors) > 1:
            return make_response(json.dumps(errors), 400)

    # For each of the schedule types, creates Schedule objects and ScheduledEvent objects
    weekly_timings = json.loads(request.values['weekly_timings'])
    w_duplicated = WeeklySchedule.create_weekly_schedules(weekly_timings, survey)
    repopulate_weekly_survey_schedule_events(survey)
    absolute_timings = json.loads(request.values['absolute_timings'])
    a_duplicated = AbsoluteSchedule.create_absolute_schedules(absolute_timings, survey)
    repopulate_absolute_survey_schedule_events(survey)
    relative_timings = json.loads(request.values['relative_timings'])
    r_duplicated = RelativeSchedule.create_relative_schedules(relative_timings, survey)
    repopulate_relative_survey_schedule_events(survey)

    # These three all stay JSON when added to survey
    content = json.dumps(content)
    settings = request.values['settings']
    survey.update(content=content, settings=settings)

    # if any duplicate schedules were submitted, flash a message
    if w_duplicated or a_duplicated or r_duplicated:
        flash('Duplicate schedule was submitted. Only one of the duplicates was created.', 'success')
    return make_response("", 201)

    Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects
    content, weekly_timings, absolute_timings, relative_timings, and settings in the request body
    
Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects
content, weekly_timings, absolute_timings, relative_timings, and settings in the request body
Updates the survey when the ' Save & Deploy button on the edit_survey page is hit . Expects content weekly_timings absolute_timings relative_timings and settings in the request body
def update_survey(survey_id=None):
    try:
        survey = Survey.objects.get(pk=survey_id)
    except Survey.DoesNotExist:
        return abort(404)
    json_content = request.values.get('content')
    content = None
    if json_content != '""':
        content = recursive_survey_content_json_decode(json_content)
        content = make_slider_min_max_values_strings(content)
    if survey.survey_type == Survey.TRACKING_SURVEY:
        errors = do_validate_survey(content)
        if len(errors) > 1:
            return make_response(json.dumps(errors), 400)
    weekly_timings = json.loads(request.values['weekly_timings'])
    w_duplicated = WeeklySchedule.create_weekly_schedules(weekly_timings, survey)
    repopulate_weekly_survey_schedule_events(survey)
    absolute_timings = json.loads(request.values['absolute_timings'])
    a_duplicated = AbsoluteSchedule.create_absolute_schedules(absolute_timings, survey)
    repopulate_absolute_survey_schedule_events(survey)
    relative_timings = json.loads(request.values['relative_timings'])
    r_duplicated = RelativeSchedule.create_relative_schedules(relative_timings, survey)
    repopulate_relative_survey_schedule_events(survey)
    content = json.dumps(content)
    settings = request.values['settings']
    survey.update(content=content, settings=settings)
    if w_duplicated or a_duplicated or r_duplicated:
        flash('Duplicate schedule was submitted. Only one of the duplicates was created.', 'success')
    return make_response("", 201)
def update_survey ( survey_id = None ) : try : survey = Survey . objects . get ( pk = survey_id ) except Survey . DoesNotExist : return abort ( 404 ) json_content = request . values . get ( 'content' ) content = None if json_content != '""' : content = recursive_survey_content_json_decode ( json_content ) content = make_slider_min_max_values_strings ( content ) if survey . survey_type == Survey . TRACKING_SURVEY : errors = do_validate_survey ( content ) if len ( errors ) > 1 : return make_response ( json . dumps ( errors ) , 400 ) weekly_timings = json . loads ( request . values [ 'weekly_timings' ] ) w_duplicated = WeeklySchedule . create_weekly_schedules ( weekly_timings , survey ) repopulate_weekly_survey_schedule_events ( survey ) absolute_timings = json . loads ( request . values [ 'absolute_timings' ] ) a_duplicated = AbsoluteSchedule . create_absolute_schedules ( absolute_timings , survey ) repopulate_absolute_survey_schedule_events ( survey ) relative_timings = json . loads ( request . values [ 'relative_timings' ] ) r_duplicated = RelativeSchedule . create_relative_schedules ( relative_timings , survey ) repopulate_relative_survey_schedule_events ( survey ) content = json . dumps ( content ) settings = request . values [ 'settings' ] survey . update ( content = content , settings = settings ) if w_duplicated or a_duplicated or r_duplicated : flash ( 'Duplicate schedule was submitted. Only one of the duplicates was created.' , 'success' ) return make_response ( "" , 201 )
Updates the survey when the 'Save & Deploy button on the edit_survey page is hit.
Updates the survey when the ' Save & Deploy button on the edit_survey page is hit .
"""
    Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects
    content, weekly_timings, absolute_timings, relative_timings, and settings in the request body
    """ # BUG: There is an unknown situation where the frontend sends a string requiring an extra
 # deserialization operation, causing 'content' to be a string containing a json string
 # containing a json list, instead of just a string containing a json list.
 # Weird corner case: the Image survey does not have any content associated with it. Therefore,
 # when you try and make a post request to save any settings you have, it gives you a 500 error
 # because the request.values.get('content') returns a json item of "". The recursive_survey_content_json_decode
 # function is not able to decode 2 double quotations marks. This is why retrieving the json_content from the post
 # request is put outside of the decode statement. HOWEVER, evaluating json_content == "" returns false, since the
 # LITERAL value of the json_content is 2 quotation marks, NOT an empty string. Thus, we need to compare the
 # json_content to a string of 2 quotation marks (ie. '""')
 # For each of the schedule types, creates Schedule objects and ScheduledEvent objects
 # These three all stay JSON when added to survey
 # if any duplicate schedules were submitted, flash a message

survey_id