Modifications as suggested by Nick Hall:
* Remove inheritance of Citation from RefBase, using source_handle filed instead (similar to the way Family objects store mother and father handles) (also use the set_ and get_reference_handle functions more consistently) * Use get_citation_list instead of get_citation_references (more consistent with the way notes are handled) svn: r18100
This commit is contained in:
parent
bad963e150
commit
bb854ec772
@ -1473,7 +1473,7 @@ def navigation_label(db, nav_type, handle):
|
||||
obj = db.get_citation_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_page()
|
||||
src = db.get_source_from_handle(obj.ref)
|
||||
src = db.get_source_from_handle(obj.get_reference_handle())
|
||||
if src:
|
||||
label = src.get_title() + " " + label
|
||||
elif nav_type == 'Repository':
|
||||
|
@ -43,14 +43,13 @@ from gen.lib.primaryobj import PrimaryObject
|
||||
from gen.lib.mediabase import MediaBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.datebase import DateBase
|
||||
from gen.lib.refbase import RefBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Citation class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
|
||||
"""
|
||||
A record of a citation of a source of information.
|
||||
|
||||
@ -71,7 +70,7 @@ class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
MediaBase.__init__(self) # 7
|
||||
NoteBase.__init__(self) # 6
|
||||
DateBase.__init__(self) # 2
|
||||
RefBase.__init__(self) # 5
|
||||
self.source_handle = None, # 5
|
||||
self.page = "" # 3
|
||||
self.confidence = Citation.CONF_NORMAL # 4
|
||||
self.datamap = {} # 8
|
||||
@ -85,7 +84,7 @@ class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
DateBase.serialize(self), # 2
|
||||
unicode(self.page), # 3
|
||||
self.confidence, # 4
|
||||
RefBase.serialize(self), # 5
|
||||
self.source_handle, # 5
|
||||
NoteBase.serialize(self), # 6
|
||||
MediaBase.serialize(self), # 7
|
||||
self.datamap, # 8
|
||||
@ -102,7 +101,7 @@ class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
date, # 2
|
||||
self.page, # 3
|
||||
self.confidence, # 4
|
||||
ref, # 5
|
||||
self.source_handle, # 5
|
||||
note_list, # 6
|
||||
media_list, # 7
|
||||
self.datamap, # 8
|
||||
@ -113,7 +112,6 @@ class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
DateBase.unserialize(self, date)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
MediaBase.unserialize(self, media_list)
|
||||
RefBase.unserialize(self, ref)
|
||||
|
||||
def _has_handle_reference(self, classname, handle):
|
||||
"""
|
||||
@ -161,8 +159,8 @@ class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
:type new_handle: str
|
||||
"""
|
||||
if classname == 'Source' and \
|
||||
RefBase.get_reference_handle(self) == old_handle:
|
||||
self.ref = RefBase.set_reference_handle(self, new_handle)
|
||||
self.get_reference_handle() == old_handle:
|
||||
self.set_reference_handle(new_handle)
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
@ -224,8 +222,8 @@ class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
if self.ref:
|
||||
ret += [('Source', self.ref)]
|
||||
if self.get_reference_handle():
|
||||
ret += [('Source', self.get_reference_handle())]
|
||||
return ret
|
||||
|
||||
def has_source_reference(self, src_handle) :
|
||||
@ -322,3 +320,9 @@ class Citation(MediaBase, NoteBase, PrimaryObject, RefBase, DateBase):
|
||||
def get_page(self):
|
||||
"""Get the page indicator of the Citation."""
|
||||
return self.page
|
||||
|
||||
def set_reference_handle(self, val):
|
||||
self.source_handle = val
|
||||
|
||||
def get_reference_handle(self):
|
||||
return self.source_handle
|
||||
|
@ -113,16 +113,6 @@ class CitationBase(object):
|
||||
for item in self.get_citation_child_list():
|
||||
item.remove_citation(handle)
|
||||
|
||||
def get_citation_references(self) :
|
||||
"""
|
||||
Return the list of citations associated with the object.
|
||||
|
||||
:returns: Returns the list of :class:`~gen.lib.Citation` handles
|
||||
associated with the object.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.citation_list
|
||||
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
@ -275,13 +275,13 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
self.__description != other.__description \
|
||||
or self.private != other.private or \
|
||||
(not self.get_date_object().is_equal(other.get_date_object())) or \
|
||||
len(self.get_citation_references()) != \
|
||||
len(other.get_citation_references()):
|
||||
len(self.get_citation_list()) != \
|
||||
len(other.get_citation_list()):
|
||||
return False
|
||||
|
||||
index = 0
|
||||
olist = other.get_citation_references()
|
||||
for a in self.get_citation_references():
|
||||
olist = other.get_citation_list()
|
||||
for a in self.get_citation_list():
|
||||
if not a.is_equal(olist[index]):
|
||||
return False
|
||||
index += 1
|
||||
|
@ -130,7 +130,7 @@ class NameModel(gtk.TreeStore):
|
||||
row=self.row(self.DEFINDEX, defname))
|
||||
|
||||
def hassource(self, name):
|
||||
if len(name.get_citation_references()):
|
||||
if len(name.get_citation_list()):
|
||||
return YES
|
||||
return NO
|
||||
|
||||
|
@ -374,7 +374,7 @@ class EditCitation(EditPrimary):
|
||||
self.db.commit_source(self.source, trans)
|
||||
msg = _("Edit Source (%s)") % self.source.get_title()
|
||||
|
||||
self.obj.ref = self.source.handle
|
||||
self.obj.set_reference_handle(self.source.handle)
|
||||
|
||||
# Now commit the Citation Primary object
|
||||
if not self.obj.get_handle():
|
||||
|
@ -533,7 +533,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
|
||||
self.write_note_list(person.get_note_list(),index+1)
|
||||
|
||||
for citation_handle in person.get_citation_references():
|
||||
for citation_handle in person.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+2)
|
||||
|
||||
for tag_handle in person.get_tag_list():
|
||||
@ -561,7 +561,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
self.dump_child_ref(child_ref,index+1)
|
||||
self.write_attribute_list(family.get_attribute_list())
|
||||
self.write_note_list(family.get_note_list(),index+1)
|
||||
for citation_handle in family.get_citation_references():
|
||||
for citation_handle in family.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+1)
|
||||
|
||||
for tag_handle in family.get_tag_list():
|
||||
@ -625,7 +625,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
self.write_line("postal",address.get_postal_code(),index+1)
|
||||
self.write_line("phone",address.get_phone(),index+1)
|
||||
self.write_note_list(address.get_note_list(),index+1)
|
||||
for citation_handle in address.get_citation_references():
|
||||
for citation_handle in address.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+1)
|
||||
self.g.write('%s</address>\n' % sp)
|
||||
|
||||
@ -636,7 +636,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
priv_text = conf_priv(personref)
|
||||
rel_text = ' rel="%s"' % escxml(personref.get_relation())
|
||||
|
||||
citation_list = personref.get_citation_references()
|
||||
citation_list = personref.get_citation_list()
|
||||
nreflist = personref.get_note_list()
|
||||
if (len(citation_list) + len(nreflist) == 0):
|
||||
self.write_ref('personref',personref.ref,index,close=True,
|
||||
@ -663,7 +663,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
mrel_text = ''
|
||||
else:
|
||||
mrel_text = ' mrel="%s"' % escxml(childref.mrel.xml_str())
|
||||
citation_list = childref.get_citation_references()
|
||||
citation_list = childref.get_citation_list()
|
||||
nreflist = childref.get_note_list()
|
||||
if (len(citation_list)+len(nreflist) == 0):
|
||||
self.write_ref('childref',childref.ref,index,close=True,
|
||||
@ -714,7 +714,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
self.write_attribute_list(event.get_attribute_list(),index+1)
|
||||
self.write_note_list(event.get_note_list(),index+1)
|
||||
|
||||
for citation_handle in event.get_citation_references():
|
||||
for citation_handle in event.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+1)
|
||||
self.write_media_list(event.get_media_list(),index+1)
|
||||
self.g.write("%s</event>\n" % sp)
|
||||
@ -741,7 +741,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
self.g.write('%s<sealed_to hlink="%s"/>\n' %
|
||||
(sp2,"_"+ord.get_family_handle()))
|
||||
self.write_note_list(ord.get_note_list(),index+1)
|
||||
for citation_handle in ord.get_citation_references():
|
||||
for citation_handle in ord.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+1)
|
||||
self.g.write('%s</lds_ord>\n' % sp)
|
||||
|
||||
@ -950,7 +950,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
if name.date:
|
||||
self.write_date(name.date,4)
|
||||
self.write_note_list(name.get_note_list(),index+1)
|
||||
for citation_handle in name.get_citation_references():
|
||||
for citation_handle in name.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+1)
|
||||
|
||||
self.g.write('%s</name>\n' % sp)
|
||||
@ -1031,7 +1031,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
(sp,conf_priv(attr),escxml(attr.get_type().xml_str()),
|
||||
self.fix(attr.get_value()))
|
||||
)
|
||||
citation_list = attr.get_citation_references()
|
||||
citation_list = attr.get_citation_list()
|
||||
nlist = attr.get_note_list()
|
||||
if (len(nlist)+len(citation_list)) == 0:
|
||||
self.g.write('/>\n')
|
||||
@ -1050,7 +1050,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
if photo.get_privacy():
|
||||
self.g.write(' priv="1"')
|
||||
proplist = photo.get_attribute_list()
|
||||
citation_list = photo.get_citation_references()
|
||||
citation_list = photo.get_citation_list()
|
||||
nreflist = photo.get_note_list()
|
||||
rect = photo.get_rectangle()
|
||||
if rect is not None :
|
||||
@ -1163,7 +1163,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
llen = (len(place.get_alternate_locations()) +
|
||||
len(place.get_url_list()) +
|
||||
len(place.get_media_list()) +
|
||||
len(place.get_citation_references())
|
||||
len(place.get_citation_list())
|
||||
)
|
||||
|
||||
ml_empty = main_loc.is_empty()
|
||||
@ -1180,7 +1180,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
self.write_media_list(place.get_media_list(), index+1)
|
||||
self.write_url_list(place.get_url_list())
|
||||
self.write_note_list(place.get_note_list(), index+1)
|
||||
for citation_handle in place.get_citation_references():
|
||||
for citation_handle in place.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+1)
|
||||
self.g.write("%s</placeobj>\n" % (" "*index))
|
||||
|
||||
@ -1210,7 +1210,7 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
dval = obj.get_date_object()
|
||||
if not dval.is_empty():
|
||||
self.write_date(dval, index+1)
|
||||
for citation_handle in obj.get_citation_references():
|
||||
for citation_handle in obj.get_citation_list():
|
||||
self.write_ref("citationref", citation_handle, index+1)
|
||||
|
||||
for tag_handle in obj.get_tag_list():
|
||||
|
@ -51,7 +51,7 @@ class Citations(Gramplet):
|
||||
return top
|
||||
|
||||
def add_citations(self, obj):
|
||||
for citation_handle in obj.get_citation_references():
|
||||
for citation_handle in obj.get_citation_list():
|
||||
self.add_citation_ref(citation_handle)
|
||||
|
||||
def add_name_citations(self, obj):
|
||||
@ -115,13 +115,14 @@ class Citations(Gramplet):
|
||||
"""
|
||||
citation = self.dbstate.db.get_citation_from_handle(citation_handle)
|
||||
page = citation.get_page()
|
||||
source = self.dbstate.db.get_source_from_handle(citation.ref)
|
||||
source_handle = citation.get_reference_handle()
|
||||
source = self.dbstate.db.get_source_from_handle(source_handle)
|
||||
title = source.get_title()
|
||||
author = source.get_author()
|
||||
self.model.add((citation_handle, title, page, author))
|
||||
|
||||
def check_citations(self, obj):
|
||||
return True if obj.get_citation_references() else False
|
||||
return True if obj.get_citation_list() else False
|
||||
|
||||
def check_name_citations(self, obj):
|
||||
names = [obj.get_primary_name()] + obj.get_alternate_names()
|
||||
@ -214,7 +215,8 @@ class Citations(Gramplet):
|
||||
handle = model.get_value(iter_, 0)
|
||||
try:
|
||||
citation = self.dbstate.db.get_citation_from_handle(handle)
|
||||
source = self.dbstate.db.get_source_from_handle(citation.ref)
|
||||
source_handle = citation.get_reference_handle()
|
||||
source = self.dbstate.db.get_source_from_handle(source_handle)
|
||||
EditCitation(self.dbstate, self.uistate, [], citation, source)
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user