2007-07-17 Alex Roitman <shura@gramps-project.org>

* src/GrampsDb/_GrampsBSDDB.py (convert_notes_13): Add reporef
	privacy on upgrade.
	* src/GrampsDbUtils/_ReadXML.py (start_note): Set privacy for
	reporef's notes;
	(start_reporef): Parse prvacy attribute for reporefs.
	* src/GrampsDb/_GrampsDbWriteXML.py (write_reporef_list): Write
	privacy attribitue.
	* src/RelLib/_RepoRef.py: Add privacy.



svn: r8730
This commit is contained in:
Alex Roitman 2007-07-17 22:44:24 +00:00
parent b844387775
commit 301348a0df
5 changed files with 31 additions and 9 deletions

View File

@ -1,3 +1,13 @@
2007-07-17 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_GrampsBSDDB.py (convert_notes_13): Add reporef
privacy on upgrade.
* src/GrampsDbUtils/_ReadXML.py (start_note): Set privacy for
reporef's notes;
(start_reporef): Parse prvacy attribute for reporefs.
* src/GrampsDb/_GrampsDbWriteXML.py (write_reporef_list): Write
privacy attribitue.
* src/RelLib/_RepoRef.py: Add privacy.
2007-07-17 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/Spell.py: Complete list of official dictionaries.

View File

@ -2065,7 +2065,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback):
(note, ref, call_number, media_type) = obj
(note_list, note_handles) = self.convert_notes_13('Note', note,
nttype=NoteType.REPOREF)
new_obj = (note_list, ref, call_number, media_type)
# Add the privacy field with 'False' content
new_obj = (note_list, ref, call_number, media_type, False)
elif name == 'SourceRef':
(date, priv, note, conf, ref, page, text) = obj
(note_list, note_handles) = self.convert_notes_13('Note', note,

View File

@ -968,6 +968,11 @@ class GrampsDbXmlWriter(object):
if not reporef or not reporef.ref:
continue
if reporef.get_privacy():
priv_text = ' priv="1"'
else:
priv_text = ''
if reporef.call_number == "":
callno_text = ''
else:
@ -981,11 +986,11 @@ class GrampsDbXmlWriter(object):
note_list = reporef.get_note_list()
if len(note_list) == 0:
self.write_ref('reporef',reporef.ref,index,
close=True,extra_text=callno_text+type_text)
self.write_ref('reporef',reporef.ref,index,close=True,
extra_text=priv_text+callno_text+type_text)
else:
self.write_ref('reporef',reporef.ref,index,
close=False,extra_text=callno_text+type_text)
self.write_ref('reporef',reporef.ref,index,close=False,
extra_text=priv_text+callno_text+type_text)
self.write_note_list(note_list,index+1)
sp = " "*index
self.g.write('%s</reporef>\n' % sp)

View File

@ -1201,7 +1201,7 @@ class GrampsParser(UpdateCallback):
self.note.private = self.repo.private
elif self.reporef:
self.note.type.set(RelLib.NoteType.REPOREF)
# reporef has no private, correct
self.note.private = self.reporef.private
self.db.add_note(self.note,self.trans)
@ -1309,6 +1309,7 @@ class GrampsParser(UpdateCallback):
self.reporef.ref = handle
self.reporef.call_number = attrs.get('callno','')
self.reporef.media_type.set_from_xml_str(attrs['medium'])
self.reporef.private = bool(attrs.get("priv"))
# we count here on self.source being available
# reporefs can only be found within source
self.source.add_repo_reference(self.reporef)

View File

@ -32,6 +32,7 @@ __revision__ = "$Revision$"
#
#-------------------------------------------------------------------------
from _SecondaryObject import SecondaryObject
from _PrivacyBase import PrivacyBase
from _NoteBase import NoteBase
from _RefBase import RefBase
from _SourceMediaType import SourceMediaType
@ -41,13 +42,14 @@ from _SourceMediaType import SourceMediaType
# Repository Reference for Sources
#
#-------------------------------------------------------------------------
class RepoRef(SecondaryObject, NoteBase, RefBase):
class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
"""
Repository reference class.
"""
def __init__(self, source=None):
SecondaryObject.__init__(self)
PrivacyBase.__init__(self, source)
NoteBase.__init__(self, source)
RefBase.__init__(self, source)
if source:
@ -64,14 +66,17 @@ class RepoRef(SecondaryObject, NoteBase, RefBase):
return (
NoteBase.serialize(self),
RefBase.serialize(self),
self.call_number, self.media_type.serialize())
self.call_number, self.media_type.serialize(),
PrivacyBase.serialize(self),
)
def unserialize(self, data):
"""
Converts a serialized tuple of data to an object
"""
(note_list, ref, self.call_number, media_type) = data
(note_list, ref, self.call_number, media_type, privacy) = data
self.media_type.unserialize(media_type)
PrivacyBase.unserialize(self, privacy)
NoteBase.unserialize(self, note_list)
RefBase.unserialize(self, ref)
return self