def _save_import_export_settings(settings): settings = {key: settings[key] for key in settings if key not in ['icolumns', 'columns', 'database', 'schema', 'table', 'save_btn_icon']} if settings['is_import']: settings['import_file_name'] = settings['filename'] else: settings['export_file_name'] = settings['filename'] # Get existing setting - old_settings = get_setting('import_export_setting') if old_settings and old_settings != 'null': old_settings = json.loads(old_settings) old_settings.update(settings) settings = json.dumps(settings) else: if 'import_file_name' not in settings: settings['import_file_name'] = '' elif 'export_file_name' not in settings: settings['export_file_name'] = '' settings = json.dumps(settings) store_setting('import_export_setting', settings)
def index(): """Render and process the main browser window.""" # Register Gravatar module with the app only if required if config.SHOW_GRAVATAR_IMAGE: Gravatar(current_app, size=100, rating='g', default='retro', force_default=False, use_ssl=True, base_url=None) # Check the browser is a supported version # NOTE: If the checks here are updated, make sure the supported versions # at https://www.pgadmin.org/faq/#11 are updated to match! if config.CHECK_SUPPORTED_BROWSER: browser_name, browser_known, version = _get_supported_browser() if browser_name is not None: msg = render_template(MODULE_NAME + "/browser.html", version=version, browser=browser_name, known=browser_known) flash(msg, 'warning') # Get the current version info from the website, and flash a message if # the user is out of date, and the check is enabled. if config.UPGRADE_CHECK_ENABLED: last_check = get_setting('LastUpdateCheck', default='0') today = time.strftime('%Y%m%d') if int(last_check) < int(today): check_browser_upgrade() store_setting('LastUpdateCheck', today) auth_only_internal = False auth_source = [] session['allow_save_password'] = True if config.SERVER_MODE: if len(config.AUTHENTICATION_SOURCES) == 1\ and INTERNAL in config.AUTHENTICATION_SOURCES: auth_only_internal = True auth_source = session['_auth_source_manager_obj'][ 'source_friendly_name'] if session['_auth_source_manager_obj']['current_source'] == KERBEROS: session['allow_save_password'] = False response = Response( render_template(MODULE_NAME + "/index.html", username=current_user.username, auth_source=auth_source, is_admin=current_user.has_role("Administrator"), logout_url=_get_logout_url(), _=gettext, auth_only_internal=auth_only_internal)) # Set the language cookie after login, so next time the user will have that # same option at the login time. misc_preference = Preferences.module('misc') user_languages = misc_preference.preference('user_language') language = 'en' if user_languages: language = user_languages.get() or 'en' domain = dict() if config.COOKIE_DEFAULT_DOMAIN and\ config.COOKIE_DEFAULT_DOMAIN != 'localhost': domain['domain'] = config.COOKIE_DEFAULT_DOMAIN 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