예제 #1
0
def db_update_step(session, tid, step_id, step_dict, language):
    """
    Update the specified step with the details.

    :param session: the session on which perform queries.
    :param step_id: the step_id of the step to update
    :param step_dict: the step definition dict
    :param language: the language of the step definition dict
    :return: a serialization of the object
    """
    step = models.db_get(
        session, models.Step, models.Step.id == step_id,
        models.Questionnaire.id == models.Step.questionnaire_id,
        models.Questionnaire.tid == tid)

    fill_localized_keys(step_dict, models.Step.localized_keys, language)

    step.update(step_dict)

    for child in step_dict['children']:
        db_update_field(session, tid, child['id'], child, language)

    db_reset_option_triggers(session, 'step', step.id)

    for trigger in step_dict.get('triggered_by_options', []):
        db_create_trigger(session, tid, trigger['option'], 'step', step.id,
                          trigger.get('sufficient', True))

    return step
예제 #2
0
def db_update_step(session, tid, step_id, request, language):
    """
    Transaction for updating a step

    :param session: An ORM session
    :param tid: The tenant ID
    :param step_id: the step_id of the step to update
    :param request: the step definition dict
    :param language: the language of the step definition dict
    :return: a serialization of the object
    """
    step = models.db_get(
        session, models.Step, models.Step.id == step_id,
        models.Questionnaire.id == models.Step.questionnaire_id,
        models.Questionnaire.tid == tid)

    fill_localized_keys(request, models.Step.localized_keys, language)

    step.update(request)

    for child in request['children']:
        db_update_field(session, tid, child['id'], child, language)

    db_reset_option_triggers(session, 'step', step.id)

    for trigger in request.get('triggered_by_options', []):
        db_create_option_trigger(session, trigger['option'], 'step', step.id,
                                 trigger.get('sufficient', True))

    return serialize_step(session, tid, step, language)
예제 #3
0
파일: step.py 프로젝트: chojar/GlobaLeaks
def db_update_step(session, tid, step_id, step_dict, language):
    """
    Update the specified step with the details.

    :param session: the session on which perform queries.
    :param step_id: the step_id of the step to update
    :param step_dict: the step definition dict
    :param language: the language of the step definition dict
    :return: a serialization of the object
    """
    step = models.db_get(session, models.Step, models.Step.id == step_id,
                                               models.Questionnaire.id == models.Step.questionnaire_id,
                                               models.Questionnaire.tid == tid)

    fill_localized_keys(step_dict, models.Step.localized_keys, language)

    step.update(step_dict)

    for child in step_dict['children']:
        db_update_field(session, tid, child['id'], child, language)

    db_reset_option_triggers(session, 'step', step.id)

    for trigger in step_dict.get('triggered_by_options', []):
        db_create_trigger(session, tid, trigger['option'], 'step', step.id, trigger.get('sufficient', True))

    return step
예제 #4
0
def db_update_step(store, step_id, request, language):
    """
    Update the specified step with the details.

    :param store: the store on which perform queries.
    :param step_id: the step_id of the step to update
    :param request: the step definition dict
    :param language: the language of the step definition dict
    :return: a serialization of the object
    """
    step = models.db_get(store, models.Step, id=step_id)

    fill_localized_keys(request, models.Step.localized_keys, language)

    step.update(request)

    for child in request['children']:
        db_update_field(store, child['id'], child, language)

    return step
예제 #5
0
def db_update_step(store, step_id, request, language):
    """
    Update the specified step with the details.
    raises :class:`globaleaks.errors.StepIdNotFound` if the step does
    not exist.

    :param store: the store on which perform queries.
    :param step_id: the step_id of the step to update
    :param request: the step definition dict
    :param language: the language of the step definition dict
    :return: a serialization of the object
    """
    step = models.Step.get(store, step_id)
    if not step:
        raise errors.StepIdNotFound

    fill_localized_keys(request, models.Step.localized_keys, language)

    step.update(request)

    for child in request['children']:
        db_update_field(store, child['id'], child, language)

    return step
예제 #6
0
파일: step.py 프로젝트: flipchan/GlobaLeaks
def db_update_step(store, step_id, request, language):
    """
    Update the specified step with the details.
    raises :class:`globaleaks.errors.StepIdNotFound` if the step does
    not exist.

    :param store: the store on which perform queries.
    :param step_id: the step_id of the step to update
    :param request: the step definition dict
    :param language: the language of the step definition dict
    :return: a serialization of the object
    """
    step = models.Step.get(store, step_id)
    if not step:
        raise errors.StepIdNotFound

    fill_localized_keys(request, models.Step.localized_keys, language)

    step.update(request)

    for child in request['children']:
        db_update_field(store, child['id'], child, language)

    return step