示例#1
0
def device_settings(study_id=None):
    study = Study.objects.get(pk=study_id)
    researcher = get_session_researcher()
    readonly = True if not researcher.check_study_admin(
        study_id) and not researcher.site_admin else False

    # if read only....
    if request.method == 'GET':
        return render_template(
            "device_settings.html",
            study=study.as_unpacked_native_python(),
            settings=study.device_settings.as_unpacked_native_python(),
            readonly=readonly,
        )

    if readonly:
        abort(403)

    params = {
        k: v
        for k, v in request.values.items()
        if not k.startswith("consent_section")
    }
    consent_sections = {
        k: v
        for k, v in request.values.items() if k.startswith("consent_section")
    }
    params = checkbox_to_boolean(CHECKBOX_TOGGLES, params)
    params = string_to_int(TIMER_VALUES, params)
    # the ios consent sections are a json field but the frontend returns something weird,
    # see the documentation in unflatten_consent_sections for details
    params["consent_sections"] = json.dumps(
        unflatten_consent_sections(consent_sections))
    study.device_settings.update(**params)
    return redirect('/edit_study/{:d}'.format(study.id))
def device_settings(study_id=None):
    study = Study.objects.get(pk=study_id)
    readonly = not admin_is_system_admin()

    if request.method == 'GET':
        settings = study.get_study_device_settings()
        return render_template(
            "device_settings.html",
            study=study.as_native_python(),
            allowed_studies=get_admins_allowed_studies(),
            settings=settings.as_native_python(),
            readonly=not admin_is_system_admin(),
            system_admin=admin_is_system_admin()
        )
    
    if readonly:
        abort(403)
        
    settings = study.get_study_device_settings()
    params = {k:v for k,v in request.values.iteritems() if not k.startswith("consent_section")}
    consent_sections = {k: v for k, v in request.values.iteritems() if k.startswith("consent_section")}
    params = checkbox_to_boolean(CHECKBOX_TOGGLES, params)
    params = string_to_int(TIMER_VALUES, params)
    # the ios consent sections are a json field but the frontend returns something weird,
    # see the documentation in unflatten_consent_sections for details
    params["consent_sections"] = json.dumps(unflatten_consent_sections(consent_sections))
    settings.update(**params)
    return redirect('/edit_study/{:d}'.format(study.id))
def device_settings(study_id=None):
    study = Study(study_id)
    readonly = not admin_is_system_admin()
    if request.method == 'GET':
        settings = study.get_study_device_settings()
        return render_template("device_settings.html",
                               study=study,
                               settings=settings,
                               readonly=not admin_is_system_admin(),
                               system_admin=admin_is_system_admin())
    if readonly: abort(403)
    settings = study.get_study_device_settings()
    params = combined_multi_dict_to_dict(request.values)
    params = checkbox_to_boolean(CHECKBOX_TOGGLES, params)
    params = string_to_int(TIMER_VALUES, params)
    settings.update(**params)
    return redirect('/edit_study/' + str(study._id))
示例#4
0
def device_settings(study_id=None):
    study = Study.objects.get(pk=study_id)
    readonly = not admin_is_system_admin()

    if request.method == 'GET':
        settings = study.get_study_device_settings()
        return render_template("device_settings.html",
                               study=study.as_native_python(),
                               allowed_studies=get_admins_allowed_studies(),
                               settings=settings.as_native_python(),
                               readonly=not admin_is_system_admin(),
                               system_admin=admin_is_system_admin())

    if readonly:
        abort(403)

    settings = study.get_study_device_settings()
    params = combined_multi_dict_to_dict(request.values)
    params = checkbox_to_boolean(CHECKBOX_TOGGLES, params)
    params = string_to_int(TIMER_VALUES, params)
    settings.update(**params)
    return redirect('/edit_study/{:d}'.format(study.id))