mirror of
https://github.com/searxng/searxng.git
synced 2026-06-01 07:27:16 +02:00
[mod] typification of the preference settings
no functional change / except the missing online doc which is now available::
$ make docs.live
$ xdg-open "http://127.0.0.1:8000/admin/settings/settings_preferences.html"
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
committed by
Brock Vojkovic
parent
e1d25c5078
commit
4ac822fd7f
+6
-6
@@ -8,7 +8,7 @@ from searx.webutils import VALID_LANGUAGE_CODE
|
||||
from searx.query import RawTextQuery
|
||||
from searx.engines import categories, engines
|
||||
from searx.search.models import SearchQuery, EngineRef
|
||||
from searx.preferences import Preferences, is_locked
|
||||
from searx.preferences import Preferences
|
||||
|
||||
|
||||
# remove duplicate queries.
|
||||
@@ -53,7 +53,7 @@ def parse_pageno(form: Dict[str, str]) -> int:
|
||||
|
||||
|
||||
def parse_lang(preferences: Preferences, form: Dict[str, str], raw_text_query: RawTextQuery) -> str:
|
||||
if is_locked('language'):
|
||||
if "language" in preferences.cfg.lock:
|
||||
return preferences.get_value('language')
|
||||
# get language
|
||||
# set specific language if set on request, query or preferences
|
||||
@@ -73,7 +73,7 @@ def parse_lang(preferences: Preferences, form: Dict[str, str], raw_text_query: R
|
||||
|
||||
|
||||
def parse_safesearch(preferences: Preferences, form: Dict[str, str]) -> int:
|
||||
if is_locked('safesearch'):
|
||||
if "safesearch" in preferences.cfg.lock:
|
||||
return preferences.get_value('safesearch')
|
||||
|
||||
if 'safesearch' in form:
|
||||
@@ -135,7 +135,7 @@ def parse_category_form(query_categories: List[str], name: str, value: str) -> N
|
||||
def get_selected_categories(preferences: Preferences, form: Optional[Dict[str, str]]) -> List[str]:
|
||||
selected_categories = []
|
||||
|
||||
if not is_locked('categories') and form is not None:
|
||||
if not "categories" in preferences.cfg.lock and form is not None:
|
||||
for name, value in form.items():
|
||||
parse_category_form(selected_categories, name, value)
|
||||
|
||||
@@ -175,7 +175,7 @@ def parse_generic(preferences: Preferences, form: Dict[str, str], disabled_engin
|
||||
|
||||
# set categories/engines
|
||||
explicit_engine_list = False
|
||||
if not is_locked('categories'):
|
||||
if not "categories" in preferences.cfg.lock:
|
||||
# parse the form only if the categories are not locked
|
||||
for pd_name, pd in form.items(): # pylint: disable=invalid-name
|
||||
if pd_name == 'engines':
|
||||
@@ -266,7 +266,7 @@ def get_search_query_from_webapp(
|
||||
if query_lang == 'auto':
|
||||
query_lang = preferences.client.locale_tag or 'all'
|
||||
|
||||
if not is_locked('categories') and raw_text_query.specific:
|
||||
if not "categories" in preferences.cfg.lock and raw_text_query.specific:
|
||||
# if engines are calculated from query,
|
||||
# set categories by using that information
|
||||
query_engineref_list = raw_text_query.enginerefs
|
||||
|
||||
Reference in New Issue
Block a user