Exemplo n.º 1
0
def save(pid):
    """
    Save a specific preference.
    """
    data = request.form if request.form else json.loads(request.data.decode())

    res, msg = Preferences.save(data['mid'], data['cid'], data['id'],
                                data['value'])

    if not res:
        return internal_server_error(errormsg=msg)

    response = success_return()

    # Set cookie & session for language settings.
    # This will execute every time as could not find the better way to know
    # that which preference is getting updated.

    misc_preference = Preferences.module('miscellaneous')
    user_languages = misc_preference.preference('user_language')

    language = 'en'
    if user_languages:
        language = user_languages.get() or language

    setattr(session, 'PGADMIN_LANGUAGE', language)
    response.set_cookie("PGADMIN_LANGUAGE", language)

    return response
Exemplo n.º 2
0
def save(pid):
    """
    Save a specific preference.
    """
    data = request.form if request.form else json.loads(request.data.decode())

    res, msg = Preferences.save(data['mid'], data['cid'], data['id'],
                                data['value'])

    if not res:
        return internal_server_error(errormsg=msg)

    return success_return()
Exemplo n.º 3
0
def save():
    """
    Save a specific preference.
    """
    pref_data = get_data()

    for data in pref_data:
        if data['name'] in ['vw_edt_tab_title_placeholder',
                            'qt_tab_title_placeholder',
                            'debugger_tab_title_placeholder'] \
                and data['value'].isspace():
            data['value'] = ''

        res, msg = Preferences.save(
            data['mid'], data['category_id'], data['id'], data['value'])
        sgm.get_nodes(sgm)

        if not res:
            return internal_server_error(errormsg=msg)

        response = success_return()

        # Set cookie & session for language settings.
        # This will execute every time as could not find the better way to know
        # that which preference is getting updated.

        misc_preference = Preferences.module('misc')
        user_languages = misc_preference.preference(
            'user_language'
        )

        language = 'en'
        if user_languages:
            language = user_languages.get() or language

        domain = dict()
        if config.COOKIE_DEFAULT_DOMAIN and \
                config.COOKIE_DEFAULT_DOMAIN != 'localhost':
            domain['domain'] = config.COOKIE_DEFAULT_DOMAIN

        setattr(session, 'PGADMIN_LANGUAGE', language)
        response.set_cookie("PGADMIN_LANGUAGE", value=language,
                            path=config.COOKIE_DEFAULT_PATH,
                            secure=config.SESSION_COOKIE_SECURE,
                            httponly=config.SESSION_COOKIE_HTTPONLY,
                            samesite=config.SESSION_COOKIE_SAMESITE,
                            **domain)

    return response
Exemplo n.º 4
0
def save(pid):
    """
    Save a specific preference.
    """
    data = request.form if request.form else json.loads(request.data.decode())

    res, msg = Preferences.save(
        data['mid'], data['category_id'], data['id'], data['value'])

    if not res:
        return internal_server_error(errormsg=msg)

    response = success_return()

    # Set cookie & session for language settings.
    # This will execute every time as could not find the better way to know
    # that which preference is getting updated.

    misc_preference = Preferences.module('miscellaneous')
    user_languages = misc_preference.preference(
        'user_language'
    )

    language = 'en'
    if user_languages:
        language = user_languages.get() or language

    domain = dict()
    if config.COOKIE_DEFAULT_DOMAIN and\
            config.COOKIE_DEFAULT_DOMAIN != 'localhost':
        domain['domain'] = config.COOKIE_DEFAULT_DOMAIN

    setattr(session, 'PGADMIN_LANGUAGE', language)
    response.set_cookie("PGADMIN_LANGUAGE", value=language,
                        path=config.COOKIE_DEFAULT_PATH,
                        **domain)

    return response