6960: Error merging citations

Error merging citations containing objects with citations.
Fixed.

svn: r22936
This commit is contained in:
Vassilii Khachaturov 2013-08-29 15:28:35 +00:00
parent fe80daa608
commit 0877cdbf54

View File

@ -30,7 +30,8 @@ Provide merge capabilities for citations.
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.lib import (Person, Family, Event, Place, MediaObject, Repository) from gen.lib import (Person, Family, Event, Place,
MediaObject, Repository, Citation)
from gen.db import DbTxn from gen.db import DbTxn
from gen.ggettext import sgettext as _ from gen.ggettext import sgettext as _
import const import const
@ -225,6 +226,12 @@ class MergeCitationQuery(object):
repository.replace_citation_references(old_handle, repository.replace_citation_references(old_handle,
new_handle) new_handle)
self.database.commit_repository(repository, trans) self.database.commit_repository(repository, trans)
elif class_name == Citation.__name__:
citation = self.database.get_citation_from_handle(handle)
assert(citation.has_citation_reference(old_handle))
citation.replace_citation_references(old_handle,
new_handle)
self.database.commit_citation(citation, trans)
else: else:
raise MergeError("Encounter an object of type %s that has " raise MergeError("Encounter an object of type %s that has "
"a citation reference." % class_name) "a citation reference." % class_name)