mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Another 'right' fix for the multiple user category problem
This commit is contained in:
parent
0b0662c632
commit
df5766f02a
@ -424,6 +424,11 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
if self.db_prefs is None:
|
if self.db_prefs is None:
|
||||||
return res
|
return res
|
||||||
user_cats = self.db_prefs.get('user_categories', [])
|
user_cats = self.db_prefs.get('user_categories', [])
|
||||||
|
# translate the case of the location
|
||||||
|
for loc in user_cats:
|
||||||
|
if location == icu_lower(loc):
|
||||||
|
location = loc
|
||||||
|
break
|
||||||
if location not in user_cats:
|
if location not in user_cats:
|
||||||
return res
|
return res
|
||||||
c = set(candidates)
|
c = set(candidates)
|
||||||
@ -445,7 +450,7 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
if query and query.strip():
|
if query and query.strip():
|
||||||
# get metadata key associated with the search term. Eliminates
|
# get metadata key associated with the search term. Eliminates
|
||||||
# dealing with plurals and other aliases
|
# dealing with plurals and other aliases
|
||||||
location = self.field_metadata.search_term_to_field_key(location.lower().strip())
|
location = self.field_metadata.search_term_to_field_key(icu_lower(location.strip()))
|
||||||
if isinstance(location, list):
|
if isinstance(location, list):
|
||||||
if allow_recursion:
|
if allow_recursion:
|
||||||
for loc in location:
|
for loc in location:
|
||||||
|
@ -7,7 +7,6 @@ import copy
|
|||||||
|
|
||||||
from calibre.utils.ordered_dict import OrderedDict
|
from calibre.utils.ordered_dict import OrderedDict
|
||||||
from calibre.utils.config import tweaks
|
from calibre.utils.config import tweaks
|
||||||
from calibre.utils.icu import lower
|
|
||||||
|
|
||||||
class TagsIcons(dict):
|
class TagsIcons(dict):
|
||||||
'''
|
'''
|
||||||
@ -485,7 +484,6 @@ class FieldMetadata(dict):
|
|||||||
return self._tb_cats[key]['rec_index'] + 1
|
return self._tb_cats[key]['rec_index'] + 1
|
||||||
|
|
||||||
def add_user_category(self, label, name):
|
def add_user_category(self, label, name):
|
||||||
label = lower(label)
|
|
||||||
if label in self._tb_cats:
|
if label in self._tb_cats:
|
||||||
raise ValueError('Duplicate user field [%s]'%(label))
|
raise ValueError('Duplicate user field [%s]'%(label))
|
||||||
self._tb_cats[label] = {'table':None, 'column':None,
|
self._tb_cats[label] = {'table':None, 'column':None,
|
||||||
@ -525,7 +523,6 @@ class FieldMetadata(dict):
|
|||||||
def _add_search_terms_to_map(self, key, terms):
|
def _add_search_terms_to_map(self, key, terms):
|
||||||
if terms is not None:
|
if terms is not None:
|
||||||
for t in terms:
|
for t in terms:
|
||||||
t = t.lower()
|
|
||||||
if t in self._search_term_map:
|
if t in self._search_term_map:
|
||||||
raise ValueError('Attempt to add duplicate search term "%s"'%t)
|
raise ValueError('Attempt to add duplicate search term "%s"'%t)
|
||||||
self._search_term_map[t] = key
|
self._search_term_map[t] = key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user