mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add custom cols to the content server active link code. In the process, fix a problem where grouped search term user categories were not in the content server's field_metadata.
This commit is contained in:
parent
87dac82a1e
commit
ded402c081
@ -7,6 +7,8 @@ __docformat__ = 'restructuredtext en'
|
|||||||
Browsing book collection by tags.
|
Browsing book collection by tags.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
@ -755,13 +757,15 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
try:
|
try:
|
||||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
for cat in sorted(self.db.prefs.get('grouped_search_terms', {}),
|
for cat in sorted(self.db.prefs.get('grouped_search_terms', {}).keys(),
|
||||||
key=sort_key):
|
key=sort_key):
|
||||||
if (u'@' + cat) in data:
|
if (u'@' + cat) in data:
|
||||||
tb_cats.add_user_category(label=u'@' + cat, name=cat)
|
try:
|
||||||
|
tb_cats.add_user_category(label=u'@' + cat, name=cat)
|
||||||
|
except ValueError:
|
||||||
|
traceback.print_exc()
|
||||||
self.db.data.change_search_locations(self.db.field_metadata.get_search_terms())
|
self.db.data.change_search_locations(self.db.field_metadata.get_search_terms())
|
||||||
|
|
||||||
if len(saved_searches().names()):
|
if len(saved_searches().names()):
|
||||||
|
@ -353,12 +353,23 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
# Reconstruct the user categories, putting them into field_metadata
|
# Reconstruct the user categories, putting them into field_metadata
|
||||||
# Assumption is that someone else will fix them if they change.
|
# Assumption is that someone else will fix them if they change.
|
||||||
self.field_metadata.remove_dynamic_categories()
|
self.field_metadata.remove_dynamic_categories()
|
||||||
tb_cats = self.field_metadata
|
|
||||||
for user_cat in sorted(self.prefs.get('user_categories', {}).keys(), key=sort_key):
|
for user_cat in sorted(self.prefs.get('user_categories', {}).keys(), key=sort_key):
|
||||||
cat_name = '@' + user_cat # add the '@' to avoid name collision
|
cat_name = '@' + user_cat # add the '@' to avoid name collision
|
||||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
self.field_metadata.add_user_category(label=cat_name, name=user_cat)
|
||||||
|
|
||||||
|
# add grouped search term user categories
|
||||||
|
muc = self.prefs.get('grouped_search_make_user_categories', [])
|
||||||
|
for cat in sorted(self.prefs.get('grouped_search_terms', {}).keys(), key=sort_key):
|
||||||
|
if cat in muc:
|
||||||
|
# There is a chance that these can be duplicates of an existing
|
||||||
|
# user category. Print the exception and continue.
|
||||||
|
try:
|
||||||
|
self.field_metadata.add_user_category(label=u'@' + cat, name=cat)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
if len(saved_searches().names()):
|
if len(saved_searches().names()):
|
||||||
tb_cats.add_search_category(label='search', name=_('Searches'))
|
self.field_metadata.add_search_category(label='search', name=_('Searches'))
|
||||||
|
|
||||||
self.field_metadata.add_grouped_search_terms(
|
self.field_metadata.add_grouped_search_terms(
|
||||||
self.prefs.get('grouped_search_terms', {}))
|
self.prefs.get('grouped_search_terms', {}))
|
||||||
|
@ -603,7 +603,9 @@ class BrowseServer(object):
|
|||||||
val = ''
|
val = ''
|
||||||
if add_category_links:
|
if add_category_links:
|
||||||
added_key = False
|
added_key = False
|
||||||
if val and key in ('authors', 'publisher', 'series', 'tags'):
|
fm = mi.metadata_for_field(key)
|
||||||
|
if val and fm and fm['is_category'] and \
|
||||||
|
key != 'formats' and fm['datatype'] not in ['rating']:
|
||||||
categories = mi.get(key)
|
categories = mi.get(key)
|
||||||
if isinstance(categories, basestring):
|
if isinstance(categories, basestring):
|
||||||
categories = [categories]
|
categories = [categories]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user