Allow arbitrary changes to the identifiers field in bulk edit search/replace

This commit is contained in:
Charles Haley 2013-03-05 12:21:07 +01:00
parent 79231df21c
commit 0491992a26
2 changed files with 14 additions and 5 deletions

View File

@ -712,7 +712,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
dest_mode = self.replace_mode.currentIndex()
if self.destination_field_fm['is_csp']:
if not unicode(self.s_r_dst_ident.text()):
dest_ident = unicode(self.s_r_dst_ident.text())
if not dest_ident or (src == 'identifiers' and dest_ident == '*'):
raise Exception(_('You must specify a destination identifier type'))
if self.destination_field_fm['is_multiple']:
@ -816,13 +817,18 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
# convert the colon-separated pair strings back into a dict,
# which is what set_identifiers wants
dst_id_type = unicode(self.s_r_dst_ident.text())
if dst_id_type:
if dst_id_type and dst_id_type != '*':
v = ''.join(val)
ids = mi.get(dest)
ids[dst_id_type] = v
val = ids
else:
try:
val = dict([(t.split(':')) for t in val])
except:
raise Exception(_('Invalid identifier string. It must be a '
'comma-separated list of pairs of '
'strings separated by a colon'))
else:
val = self.s_r_replace_mode_separator().join(val)
if dest == 'title' and len(val) == 0:

View File

@ -1006,7 +1006,10 @@ not multiple and the destination field is multiple</string>
</sizepolicy>
</property>
<property name="toolTip">
<string>Choose which identifier type to operate upon</string>
<string>&lt;p&gt;Choose which identifier type to operate upon. If the
source field is something other than 'identifiers' you can enter
a * if you want to replace the entire set of identifiers with
the result of the search/replace.&lt;/p&gt;</string>
</property>
</widget>
</item>