forked from Ponysearch/Ponysearch
[enh] cleaner category/engine selection from GET/POST param - closes #289
This commit is contained in:
parent
e34166168c
commit
b6de23f540
1 changed files with 15 additions and 2 deletions
|
@ -382,9 +382,19 @@ class Search(object):
|
||||||
# otherwise, using defined categories to
|
# otherwise, using defined categories to
|
||||||
# calculate which engines should be used
|
# calculate which engines should be used
|
||||||
else:
|
else:
|
||||||
# set used categories
|
# set categories/engines
|
||||||
|
load_default_categories = True
|
||||||
for pd_name, pd in self.request_data.items():
|
for pd_name, pd in self.request_data.items():
|
||||||
if pd_name.startswith('category_'):
|
if pd_name == 'categories':
|
||||||
|
self.categories.extend(categ for categ in pd.split(',') if categ in categories)
|
||||||
|
elif pd_name == 'engines':
|
||||||
|
pd_engines = [{'category': engines[engine].categories[0],
|
||||||
|
'name': engine}
|
||||||
|
for engine in pd.split(',') if engine in engines]
|
||||||
|
if pd_engines:
|
||||||
|
self.engines.extend(pd_engines)
|
||||||
|
load_default_categories = False
|
||||||
|
elif pd_name.startswith('category_'):
|
||||||
category = pd_name[9:]
|
category = pd_name[9:]
|
||||||
|
|
||||||
# if category is not found in list, skip
|
# if category is not found in list, skip
|
||||||
|
@ -398,6 +408,9 @@ class Search(object):
|
||||||
# remove category from list if property is set to 'off'
|
# remove category from list if property is set to 'off'
|
||||||
self.categories.remove(category)
|
self.categories.remove(category)
|
||||||
|
|
||||||
|
if not load_default_categories:
|
||||||
|
return
|
||||||
|
|
||||||
# if no category is specified for this search,
|
# if no category is specified for this search,
|
||||||
# using user-defined default-configuration which
|
# using user-defined default-configuration which
|
||||||
# (is stored in cookie)
|
# (is stored in cookie)
|
||||||
|
|
Loading…
Reference in a new issue