diff options
author | Noémi Ványi <sitbackandwait@gmail.com> | 2020-10-23 16:22:55 +0200 |
---|---|---|
committer | Noémi Ványi <sitbackandwait@gmail.com> | 2020-10-25 18:06:18 +0100 |
commit | 33e139cae64bb78157ebca56a5d1a752da95555a (patch) | |
tree | bf4ff91f497f4ec5941acca7ac0fc23e315536cc /searx/webadapter.py | |
parent | 6beb84efb8c8b62f1dfa9e7af33db73c06fabcb2 (diff) | |
download | searxng-33e139cae64bb78157ebca56a5d1a752da95555a.tar.gz searxng-33e139cae64bb78157ebca56a5d1a752da95555a.zip |
Let admins lock user preferences
Diffstat (limited to 'searx/webadapter.py')
-rw-r--r-- | searx/webadapter.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/searx/webadapter.py b/searx/webadapter.py index 7ef06b62a..e2867d99d 100644 --- a/searx/webadapter.py +++ b/searx/webadapter.py @@ -4,7 +4,7 @@ from searx.webutils import VALID_LANGUAGE_CODE from searx.query import RawTextQuery from searx.engines import categories, engines from searx.search import SearchQuery, EngineRef -from searx.preferences import Preferences +from searx.preferences import Preferences, is_locked # remove duplicate queries. @@ -48,6 +48,8 @@ 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'): + return preferences.get_value('langueage') # get language # set specific language if set on request, query or preferences # TODO support search with multible languages @@ -66,6 +68,9 @@ 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'): + return preferences.get_value('safesearch') + if 'safesearch' in form: query_safesearch = form.get('safesearch') # first check safesearch @@ -117,6 +122,9 @@ def parse_specific(raw_text_query: RawTextQuery) -> Tuple[List[EngineRef], List[ def parse_category_form(query_categories: List[str], name: str, value: str) -> None: + if is_locked('categories'): + return preferences.get_value('categories') + if name == 'categories': query_categories.extend(categ for categ in map(str.strip, value.split(',')) if categ in categories) elif name.startswith('category_'): |