Bulk metadata dialog: Fix renaming a custom series via search and replace causing the series index to be reset to 1. Fixes #1519599 [Edit custom series resets series index to 1](https://bugs.launchpad.net/calibre/+bug/1519599)

Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
Kovid Goyal 2015-11-25 20:13:14 +05:30
commit c63d75bae4
3 changed files with 9 additions and 4 deletions

View File

@ -1036,13 +1036,15 @@ class Cache(object):
if is_series:
bimap, simap = {}, {}
sfield = self.fields[name + '_index']
for k, v in book_id_to_val_map.iteritems():
if isinstance(v, basestring):
v, sid = get_series_values(v)
else:
v = sid = None
if name.startswith('#') and sid is None:
sid = 1.0 # The value will be set to 1.0 in the db table
if sid is None and name.startswith('#'):
extra = self._fast_field_for(sfield, k)
sid = extra or 1.0 # The value to be set the db link table
bimap[k] = v
if sid is not None:
simap[k] = sid

View File

@ -192,11 +192,12 @@ class WritingTest(BaseTest):
for c in (cache, cache2):
for i, val in {1:'A Series One', 2:'A Series One', 3:'Series'}.iteritems():
self.assertEqual(c.field_for('series', i), val)
cs_indices = {1:c.field_for('#series_index', 1), 3:c.field_for('#series_index', 3)}
for i in (1, 2, 3):
self.assertEqual(c.field_for('#series', i), 'Series')
for i, val in {1:2, 2:1, 3:3}.iteritems():
self.assertEqual(c.field_for('series_index', i), val)
for i, val in {1:1, 2:0, 3:1}.iteritems():
for i, val in {1:cs_indices[1], 2:0, 3:cs_indices[3]}.iteritems():
self.assertEqual(c.field_for('#series_index', i), val)
del cache2

View File

@ -118,8 +118,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
else:
fm = field_metadata[col]
if col in ['title', 'ondevice']:
if col == 'title':
coltype = _('Text')
elif col == 'ondevice':
coltype = _('Yes/No with text')
else:
dt = fm['datatype']
if fm['is_multiple']: