From d761bee9a688159dfb1b40c9cb54fdc2ee53b507 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 4 Apr 2006 18:07:23 +0000 Subject: [PATCH] Start of better LDS support svn: r6261 --- gramps2/ChangeLog | 15 +++ gramps2/src/DisplayTabs.py | 89 +++++++++++++++++ gramps2/src/Editors/Makefile.am | 1 + gramps2/src/Editors/_EditLdsOrd.py | 143 +++++++++++++++++++++++++++ gramps2/src/Editors/_EditPerson.py | 5 + gramps2/src/Editors/__init__.py | 1 + gramps2/src/GrampsDb/_GrampsBSDDB.py | 43 +++++++- gramps2/src/GrampsWidgets.py | 7 ++ gramps2/src/RelLib/Makefile.am | 1 + gramps2/src/RelLib/_Family.py | 48 +++------ gramps2/src/RelLib/_LdsOrd.py | 18 +++- gramps2/src/RelLib/_LdsOrdBase.py | 108 ++++++++++++++++++++ gramps2/src/RelLib/_Person.py | 143 ++++++++------------------- gramps2/src/glade/gramps.glade | 110 ++++++++++++++++++--- gramps2/src/lds.py | 15 ++- 15 files changed, 593 insertions(+), 154 deletions(-) create mode 100644 gramps2/src/Editors/_EditLdsOrd.py create mode 100644 gramps2/src/RelLib/_LdsOrdBase.py diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d51948eb0..3378b5e8c 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,17 @@ +2006-04-04 Don Allingham + * src/GrampsDb/_GrampsBSDDB.py: new upgrade for LDS change + * src/Editors/_EditLdsOrd.py: addedn + * src/Editors/__init__.py: add EditLdsOrd + * src/Editors/_EditPerson.py: LDS support + * src/RelLib/_LdsOrdBase.py: added + * src/RelLib/_Person.py: use a list of LdsOrds + * src/RelLib/_Family.py: use a list of LdsOrds + * src/RelLib/_LdsOrd.py: add type field + * src/DisplayTabs.py: lds tab + * src/GrampsWidgets.py: menus + * src/glade/gramps.glade: lds support + * src/lds.py: additional support + 2006-04-04 Martin Hawlisch * src/plugins/TestcaseGenerator.py: Fix lds ord; Add new option to put a linebreak into each textfield @@ -8,6 +22,7 @@ * src/plugins/DescendReport.py: fix death dates 2006-04-02 Don Allingham + * src/PluginUtils/Plugins.py: Fix args * src/GrampsWidgets.py: Fix place autocompletion * src/glade/gramps.glade: start of LDS Ord editor diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index 1e550eaa9..300b7f0b9 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -1181,6 +1181,63 @@ class AddrEmbedList(EmbeddedList): def edit_callback(self,name): self.rebuild() + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +class LdsEmbedList(EmbeddedList): + + _HANDLE_COL = 5 + _DND_TYPE = DdTargets.ADDRESS + + _column_names = [ + (_('Type'), 0, 150), + (_('Date'), 1, 150), + (_('Temple'), 2, 225), + (_('Place'), 3, 100), + ] + + def __init__(self,dbstate,uistate,track,data): + self.data = data + EmbeddedList.__init__(self, dbstate, uistate, track, + _('LDS'), LdsModel) + + def get_data(self): + return self.data + + def column_order(self): + return ((1,0),(1,1),(1,2),(1,3)) + + def add_button_clicked(self,obj): + lds = RelLib.LdsOrd() + try: + from Editors import EditLdsOrd + + EditLdsOrd(self.dbstate, self.uistate, self.track, + lds, self.add_callback) + except Errors.WindowActiveError: + pass + + def add_callback(self,name): + self.get_data().append(name) + self.rebuild() + + def edit_button_clicked(self,obj): + lds = self.get_selected() + if lds: + try: + from Editors import EditLdsOrd + + EditLdsOrd(self.dbstate, self.uistate, self.track, + lds, self.edit_callback) + except Errors.WindowActiveError: + pass + + def edit_callback(self,name): + self.rebuild() + #------------------------------------------------------------------------- # # @@ -1857,6 +1914,38 @@ class AttrModel(gtk.ListStore): def type_name(self, attr): return Utils.format_attribute( attr.get_type()) +#------------------------------------------------------------------------- +# +# LdsModel +# +#------------------------------------------------------------------------- +class LdsModel(gtk.ListStore): + + _HANDLE_COL = 5 + + def __init__(self,lds_list,db): + gtk.ListStore.__init__(self, str, str, str, str, str, object) + + import lds + + self.db = db + for lds_ord in lds_list: + self.append(row=[ + lds.ord_type[lds_ord.get_type()], + DateHandler.get_date(lds_ord), + lds_ord.get_status(), + lds_ord.get_temple(), + self.column_place(lds_ord), + lds_ord, + ]) + + def column_place(self, lds_ord): + if lds_ord: + place_handle = lds_ord.get_place_handle() + if place_handle: + return self.db.get_place_from_handle(place_handle).get_title() + return u"" + #------------------------------------------------------------------------- # # NameModel diff --git a/gramps2/src/Editors/Makefile.am b/gramps2/src/Editors/Makefile.am index ee219ff84..a9e4fc76d 100644 --- a/gramps2/src/Editors/Makefile.am +++ b/gramps2/src/Editors/Makefile.am @@ -12,6 +12,7 @@ pkgdata_PYTHON = \ _EditEvent.py \ _EditEventRef.py \ _EditFamily.py \ + _EditLdsOrd.py \ _EditLocation.py \ _EditMedia.py \ _EditMediaRef.py \ diff --git a/gramps2/src/Editors/_EditLdsOrd.py b/gramps2/src/Editors/_EditLdsOrd.py new file mode 100644 index 000000000..9e5897f13 --- /dev/null +++ b/gramps2/src/Editors/_EditLdsOrd.py @@ -0,0 +1,143 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2005 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id: _EditAttribute.py 6248 2006-03-31 23:46:34Z dallingham $ + +""" +The EditAttribute module provides the AttributeEditor class. This provides a +mechanism for the user to edit attribute information. +""" + +__author__ = "Donald N. Allingham" +__version__ = "$Revision: 6248 $" + +#------------------------------------------------------------------------- +# +# Python modules +# +#------------------------------------------------------------------------- +from TransUtils import sgettext as _ + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- +import gtk.glade + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +import const +import Utils +import RelLib +import GrampsDisplay +import lds + +from _EditSecondary import EditSecondary + +from DisplayTabs import * +from GrampsWidgets import * + +#------------------------------------------------------------------------- +# +# EditAttribute class +# +#------------------------------------------------------------------------- +class EditLdsOrd(EditSecondary): + """ + Displays a dialog that allows the user to edit an attribute. + """ + def __init__(self, state, uistate, track, attrib, callback): + """ + Displays the dialog box. + + parent - The class that called the Address editor. + attrib - The attribute that is to be edited + title - The title of the dialog box + list - list of options for the pop down menu + """ + EditSecondary.__init__(self, state, uistate, track, attrib, callback) + + def attribute_list(self): + return Utils.personal_attributes + + def _local_init(self): + self.top = gtk.glade.XML(const.gladeFile, "lds_person_edit","gramps") + self.define_top_level(self.top.get_widget("lds_person_edit"), + self.top.get_widget('title'), + _('LDS Ordinance Editor')) + + def _connect_signals(self): + self.define_cancel_button(self.top.get_widget('cancel')) + self.define_help_button(self.top.get_widget('help'),'adv-at') + self.define_ok_button(self.top.get_widget('ok'),self.save) + + def _setup_fields(self): + self.priv = PrivacyButton( + self.top.get_widget("private"), + self.obj) + + self.date_field = MonitoredDate( + self.top.get_widget("date"), + self.top.get_widget("date_stat"), + self.obj.get_date_object(), + self.window, self.db.readonly) + + self.place_field = PlaceEntry( + self.top.get_widget("place"), + self.obj.get_place_handle(), + self.dbstate.get_place_completion(), + self.db.readonly) + + temple_list = [] + for val in lds.temple_codes.keys(): + temple_list.append((lds.temple_codes[val],val)) + + def _create_tabbed_pages(self): + notebook = gtk.Notebook() + self.srcref_list = self._add_tab( + notebook, + SourceEmbedList(self.dbstate,self.uistate, self.track, + self.obj.source_list)) + + self.note_tab = self._add_tab( + notebook, + NoteTab(self.dbstate, self.uistate, self.track, + self.obj.get_note_object())) + + notebook.show_all() + vbox = self.top.get_widget('vbox').pack_start(notebook,True) + + def build_menu_names(self, attrib): + label = _("LDS Ordinance") + return (label, _('LDS Ordinance Editor')) + + def save(self,*obj): + """ + Called when the OK button is pressed. Gets data from the + form and updates the Attribute data structure. + """ + if self.callback: + self.callback(self.obj) + self.close_window(obj) + diff --git a/gramps2/src/Editors/_EditPerson.py b/gramps2/src/Editors/_EditPerson.py index 9011fb30d..7bb60bc2f 100644 --- a/gramps2/src/Editors/_EditPerson.py +++ b/gramps2/src/Editors/_EditPerson.py @@ -250,6 +250,11 @@ class EditPerson(EditPrimary): WebEmbedList(self.dbstate,self.uistate,self.track, self.obj.get_url_list())) + self.lds_list = self._add_tab( + notebook, + LdsEmbedList(self.dbstate,self.uistate,self.track, + self.obj.get_lds_ord_list())) + notebook.show_all() self.top.get_widget('vbox').pack_start(notebook,True) diff --git a/gramps2/src/Editors/__init__.py b/gramps2/src/Editors/__init__.py index 2404e36b5..2d496f8d5 100644 --- a/gramps2/src/Editors/__init__.py +++ b/gramps2/src/Editors/__init__.py @@ -23,6 +23,7 @@ from _EditAttribute import * from _EditEvent import * from _EditEventRef import * from _EditFamily import * +from _EditLdsOrd import * from _EditLocation import * from _EditMedia import * from _EditMediaRef import * diff --git a/gramps2/src/GrampsDb/_GrampsBSDDB.py b/gramps2/src/GrampsDb/_GrampsBSDDB.py index 115635eaf..c0d0aea78 100644 --- a/gramps2/src/GrampsDb/_GrampsBSDDB.py +++ b/gramps2/src/GrampsDb/_GrampsBSDDB.py @@ -56,7 +56,7 @@ from _GrampsDbBase import * import const _MINVERSION = 5 -_DBVERSION = 9 +_DBVERSION = 10 def find_surname(key,data): return str(data[3][3]) @@ -1180,6 +1180,8 @@ class GrampsBSDDB(GrampsDbBase): self.gramps_upgrade_8() if version < 9: self.gramps_upgrade_9() + if version < 10: + self.gramps_upgrade_10() # self.metadata.put('version',_DBVERSION) # self.metadata.sync() print "Upgrade time:", int(time.time()-t), "seconds" @@ -1604,6 +1606,45 @@ class GrampsBSDDB(GrampsDbBase): self.metadata.sync() print "Done upgrading to DB version 9" + def gramps_upgrade_10(self): + print "Upgrading to DB version 10" + + table_flags = self.open_flags() + self.reference_map_primary_map = db.DB(self.env) + self.reference_map_primary_map.set_flags(db.DB_DUP) + self.reference_map_primary_map.open(self.full_name, + "reference_map_primary_map", + db.DB_BTREE, flags=table_flags) + self.reference_map.associate(self.reference_map_primary_map, + find_primary_handle, + table_flags) + + trans = self.transaction_begin("",True) + + for handle in self.person_map.keys(): + val = list(self.get_raw_person_data(handle)) + lds_list = [ x for x in [val[15],val[16],val[17]] if x ] + data=tuple(val[:15]) + (lds_list,) + tuple(val[18:]) + p = Person(data=data) + self.commit_person(p,trans) + + for handle in self.family_map.keys(): + val = list(self.get_raw_family_data(handle)) + if val[9]: + data = tuple(val[:9]) + (val[9],) + tuple(val[10:]) + else: + data = tuple(val[:9]) + ([],) + tuple(val[10:]) + p = Family() + p.unserialize(data) + self.commit_family(p,trans) + + self.transaction_commit(trans,"Upgrade to DB version 10") + + self.reference_map_primary_map.close() + + self.metadata.put('version',10) + self.metadata.sync() + class BdbTransaction(Transaction): def __init__(self,msg,db,batch=False,no_magic=False): diff --git a/gramps2/src/GrampsWidgets.py b/gramps2/src/GrampsWidgets.py index 7dd516f86..ddc6b01fe 100644 --- a/gramps2/src/GrampsWidgets.py +++ b/gramps2/src/GrampsWidgets.py @@ -363,6 +363,13 @@ class MonitoredMenu: def on_change(self, obj): self.set_val(self.model.get_value(obj.get_active_iter(),1)) + + def force(self,value): + self.obj.set_active(self.data.index(value)) + + def on_change(self, obj): + value = self.data[self.model.get_value(obj.get_active_iter(),1)] + self.set_val(value) class MonitoredDate: diff --git a/gramps2/src/RelLib/Makefile.am b/gramps2/src/RelLib/Makefile.am index f791811ba..bbdd30aea 100644 --- a/gramps2/src/RelLib/Makefile.am +++ b/gramps2/src/RelLib/Makefile.am @@ -19,6 +19,7 @@ pkgdata_PYTHON = \ _Family.py\ _GenderStats.py\ __init__.py\ + _LdsOrdBase.py\ _LdsOrd.py\ _LocationBase.py\ _Location.py\ diff --git a/gramps2/src/RelLib/_Family.py b/gramps2/src/RelLib/_Family.py index e5004fe92..6d8e0b718 100644 --- a/gramps2/src/RelLib/_Family.py +++ b/gramps2/src/RelLib/_Family.py @@ -41,13 +41,14 @@ from _SourceNote import SourceNote from _MediaBase import MediaBase from _AttributeBase import AttributeBase from _EventRef import EventRef +from _LdsOrdBase import LdsOrdBase #------------------------------------------------------------------------- # # Family class # #------------------------------------------------------------------------- -class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): +class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase,LdsOrdBase): """ Introduction ============ @@ -85,6 +86,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): SourceNote.__init__(self) MediaBase.__init__(self) AttributeBase.__init__(self) + LdsOrdBase.__init__(self) self.father_handle = None self.mother_handle = None self.child_list = [] @@ -118,7 +120,8 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): [er.serialize() for er in self.event_ref_list], MediaBase.serialize(self), AttributeBase.serialize(self), - lds_seal,SourceNote.serialize(self), + LdsOrdBase.serialize(self), + SourceNote.serialize(self), self.change, self.marker, self.private) def unserialize(self, data): @@ -128,7 +131,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): """ (self.handle, self.gramps_id, self.father_handle, self.mother_handle, self.child_list, self.type, - event_ref_list, media_list, attribute_list, lds_seal, sn, + event_ref_list, media_list, attribute_list, lds_seal_list, sn, self.change,self.marker, self.private) = data self.event_ref_list = [EventRef().unserialize(er) @@ -136,6 +139,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): MediaBase.unserialize(self,media_list) AttributeBase.unserialize(self,attribute_list) SourceNote.unserialize(self,sn) + LdsOrdBase.unserialize(self,lds_seal_list) def _has_handle_reference(self,classname,handle): if classname == 'Event': @@ -143,7 +147,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): elif classname == 'Person': return handle in self.child_list + [self.father_handle,self.mother_handle] elif classname == 'Place': - return bool(self.lds_seal) and self.lds_seal.place == handle + return handle in [ x.place for x in self.lds_ord_list ] return False def _remove_handle_references(self,classname,handle_list): @@ -160,8 +164,9 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): if self.mother_handle in handle_list: self.mother_handle = None elif classname == 'Place': - if self.lds_seal and self.lds_seal.place in handle_list: - self.lds_seal.place = None + for x in self.lds_ord_list: + if x.place in handle_list: + x.place = None def _replace_handle_reference(self,classname,old_handle,new_handle): if classname == 'Event': @@ -179,8 +184,9 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): if self.mother_handle == old_handle: self.mother_handle = new_handle elif classname == 'Place': - if self.lds_seal and self.lds_seal.place == old_handle: - self.lds_seal.place = new_handle + for x in self.lds_ord_list: + if x.place == old_handle: + x.place = new_handle def get_text_data_list(self): """ @@ -198,7 +204,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): @return: Returns the list of child objects that may carry textual data. @rtype: list """ - check_list = [self.lds_seal,self.note] + check_list = self.lds_ord_list + [self.note] add_list = [item for item in check_list if item] return self.media_list + self.attribute_list + \ self.source_list + add_list @@ -210,9 +216,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): @return: Returns the list of child secondary child objects that may refer sources. @rtype: list """ - check_list = self.media_list + self.attribute_list - if self.lds_seal: - check_list.append(self.lds_seal) + check_list = self.media_list + self.attribute_list + self.lds_ord_list return check_list def get_referenced_handles(self): @@ -262,26 +266,6 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase): """ return self.complete - def set_lds_sealing(self,lds_ord): - """ - Sets the LDS Sealing ordinance. An ordinance can be removed - by assigning to None. - - @param lds_ord: L{LdsOrd} to assign as the LDS Sealing ordinance. - @type lds_ord: L{LdsOrd} - """ - self.lds_seal = lds_ord - - def get_lds_sealing(self): - """ - Returns the LDS Sealing ordinance. - - @returns: returns the L{LdsOrd} instance assigned as the LDS - Sealing ordinance, or None if no ordinance has been assigned. - @rtype: L{LdsOrd} - """ - return self.lds_seal - def set_relationship(self,relationship_type): """ Sets the relationship type between the people identified as the diff --git a/gramps2/src/RelLib/_LdsOrd.py b/gramps2/src/RelLib/_LdsOrd.py index d979ebf9f..dcc9bf2f0 100644 --- a/gramps2/src/RelLib/_LdsOrd.py +++ b/gramps2/src/RelLib/_LdsOrd.py @@ -32,13 +32,14 @@ LDS Ordinance class for GRAMPS from _SourceNote import SourceNote from _DateBase import DateBase from _PlaceBase import PlaceBase +from _PrivacyBase import PrivacyBase #------------------------------------------------------------------------- # # LDS Ordinance class # #------------------------------------------------------------------------- -class LdsOrd(SourceNote,DateBase,PlaceBase): +class LdsOrd(SourceNote,DateBase,PlaceBase,PrivacyBase): """ Class that contains information about LDS Ordinances. LDS ordinances are similar to events, but have very specific additional @@ -46,17 +47,26 @@ class LdsOrd(SourceNote,DateBase,PlaceBase): of Latter Day Saints (Morman church). The LDS church is the largest source of genealogical information in the United States. """ + + BAPTISM = 0 + ENDOWMENT = 1 + SEAL_TO_PARENTS = 2 + SEAL_TO_SPOUSE = 3 + def __init__(self,source=None): """Creates a LDS Ordinance instance""" SourceNote.__init__(self,source) DateBase.__init__(self,source) PlaceBase.__init__(self,source) + PrivacyBase.__init__(self,source) if source: + self.type = source.type self.famc = source.famc self.temple = source.temple self.status = source.status else: + self.type = self.BAPTISM self.famc = None self.temple = "" self.status = 0 @@ -117,6 +127,12 @@ class LdsOrd(SourceNote,DateBase,PlaceBase): """ return self.source_list + def get_type(self): + return self.type + + def set_type(self, ord_type): + self.type = ord_type + def set_family_handle(self,family): """Sets the Family database handle associated with the LDS ordinance""" self.famc = family diff --git a/gramps2/src/RelLib/_LdsOrdBase.py b/gramps2/src/RelLib/_LdsOrdBase.py new file mode 100644 index 000000000..b94192505 --- /dev/null +++ b/gramps2/src/RelLib/_LdsOrdBase.py @@ -0,0 +1,108 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2006 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id: _LdsOrdBase.py 5875 2006-02-03 22:03:53Z rshura $ + +""" +LdsOrdBase class for GRAMPS +""" + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from _LdsOrd import LdsOrd + +#------------------------------------------------------------------------- +# +# LdsOrdBase classes +# +#------------------------------------------------------------------------- +class LdsOrdBase: + """ + Base class for lds_ord-aware objects. + """ + + def __init__(self,source=None): + """ + Initialize a LdsOrdBase. If the source is not None, then object + is initialized from values of the source object. + + @param source: Object used to initialize the new object + @type source: LdsOrdBase + """ + + if source: + self.lds_ord_list = [ LdsOrd(lds_ord) \ + for lds_ord in source.lds_ord_list ] + else: + self.lds_ord_list = [] + + def serialize(self): + return [addr.serialize() for addr in self.lds_ord_list] + + def unserialize(self,data): + self.lds_ord_list = [LdsOrd().unserialize(item) for item in data] + + def add_lds_ord(self,lds_ord): + """ + Adds the L{LdsOrd} instance to the object's list of lds_ordes + + @param lds_ord: L{LdsOrd} instance to add to the object's lds_ord list + @type lds_ord: list + """ + self.lds_ord_list.append(lds_ord) + + def remove_lds_ord(self,lds_ord): + """ + Removes the specified L{LdsOrd} instance from the lds_ord list + If the instance does not exist in the list, the operation has + no effect. + + @param lds_ord: L{LdsOrd} instance to remove from the list + @type lds_ord: L{LdsOrd} + + @return: True if the lds_ord was removed, False if it was not in the list. + @rtype: bool + """ + if lds_ord in self.lds_ord_list: + self.lds_ord_list.remove(lds_ord) + return True + else: + return False + + def get_lds_ord_list(self): + """ + Returns the list of L{LdsOrd} instances associated with the object + + @return: Returns the list of L{LdsOrd} instances + @rtype: list + """ + return self.lds_ord_list + + def set_lds_ord_list(self,lds_ord_list): + """ + Assigns the passed list to the object's list of L{LdsOrd} instances. + @param lds_ord_list: List of L{LdsOrd} instances to be associated + with the object + @type lds_ord_list: list + """ + self.lds_ord_list = lds_ord_list diff --git a/gramps2/src/RelLib/_Person.py b/gramps2/src/RelLib/_Person.py index 56e106d9a..7e9677e31 100644 --- a/gramps2/src/RelLib/_Person.py +++ b/gramps2/src/RelLib/_Person.py @@ -41,6 +41,7 @@ from _SourceNote import SourceNote from _MediaBase import MediaBase from _AttributeBase import AttributeBase from _AddressBase import AddressBase +from _LdsOrdBase import LdsOrdBase from _UrlBase import UrlBase from _Name import Name from _EventRef import EventRef @@ -52,7 +53,7 @@ from _LdsOrd import LdsOrd # #------------------------------------------------------------------------- class Person(PrimaryObject,SourceNote, - MediaBase,AttributeBase,AddressBase,UrlBase): + MediaBase,AttributeBase,AddressBase,UrlBase,LdsOrdBase): """ Introduction ============ @@ -101,6 +102,7 @@ class Person(PrimaryObject,SourceNote, AttributeBase.__init__(self) AddressBase.__init__(self) UrlBase.__init__(self) + LdsOrdBase.__init__(self) self.primary_name = Name() self.event_ref_list = [] self.family_list = [] @@ -110,9 +112,6 @@ class Person(PrimaryObject,SourceNote, self.gender = Person.UNKNOWN self.death_ref = None self.birth_ref = None - self.lds_bapt = None - self.lds_endow = None - self.lds_seal = None if data: self.unserialize(data) @@ -145,32 +144,26 @@ class Person(PrimaryObject,SourceNote, death_ref = None else: death_ref = self.death_ref.serialize() - if self.lds_bapt == None: - lds_bapt = None - else: - lds_bapt = self.lds_bapt.serialize() - if self.lds_endow == None: - lds_endow = None - else: - lds_endow = self.lds_endow.serialize() - if self.lds_seal == None: - lds_seal = None - else: - lds_seal = self.lds_seal.serialize() - return (self.handle, self.gramps_id, self.gender, + return (self.handle, + self.gramps_id, + self.gender, self.primary_name.serialize(), [name.serialize() for name in self.alternate_names], - unicode(self.nickname), death_ref, birth_ref, + unicode(self.nickname), + death_ref, + birth_ref, [er.serialize() for er in self.event_ref_list], - self.family_list,self.parent_family_list, + self.family_list, + self.parent_family_list, MediaBase.serialize(self), AddressBase.serialize(self), AttributeBase.serialize(self), UrlBase.serialize(self), - lds_bapt, lds_endow, lds_seal, + LdsOrdBase.serialize(self), SourceNote.serialize(self), - self.change, self.marker, + self.change, + self.marker, self.private) def unserialize(self,data): @@ -182,30 +175,38 @@ class Person(PrimaryObject,SourceNote, Person object @type data: tuple """ - (self.handle, self.gramps_id, self.gender, primary_name, - alternate_names, self.nickname, death_ref, - birth_ref, event_ref_list, self.family_list, - self.parent_family_list, media_list, address_list, - attribute_list, urls, lds_bapt, lds_endow, - lds_seal, sn, self.change, - self.marker, self.private) = (data + (False,))[0:22] + (self.handle, + self.gramps_id, + self.gender, + primary_name, + alternate_names, + self.nickname, + death_ref, + birth_ref, + event_ref_list, + self.family_list, + self.parent_family_list, + media_list, + address_list, + attribute_list, + urls, + lds_ord_list, + sn, + self.change, + self.marker, + self.private) = data self.primary_name.unserialize(primary_name) if death_ref: self.death_ref = EventRef().unserialize(death_ref) if birth_ref: self.birth_ref = EventRef().unserialize(birth_ref) - if lds_bapt: - self.lds_bapt = LdsOrd().unserialize(lds_bapt) - if lds_endow: - self.lds_endow = LdsOrd().unserialize(lds_endow) - if lds_seal: - self.lds_seal = LdsOrd().unserialize(lds_seal) self.alternate_names = [Name().unserialize(name) for name in alternate_names] self.event_ref_list = [EventRef().unserialize(er) for er in event_ref_list] MediaBase.unserialize(self,media_list) + LdsOrdBase.unserialize(self,lds_ord_list) AddressBase.unserialize(self,address_list) AttributeBase.unserialize(self,attribute_list) UrlBase.unserialize(self,urls) @@ -221,9 +222,7 @@ class Person(PrimaryObject,SourceNote, return handle in self.family_list + \ [item[0] for item in self.parent_family_list ] elif classname == 'Place': - return handle in [ordinance.place - for ordinance in [self.lds_bapt,self.lds_endow,self.lds_seal] - if ordinance] + return handle in self.lds_ord_list return False def _remove_handle_references(self,classname,handle_list): @@ -243,7 +242,7 @@ class Person(PrimaryObject,SourceNote, if item[0] not in handle_list ] self.parent_family_list = new_list elif classname == 'Place': - for ordinance in [self.lds_bapt,self.lds_endow,self.lds_seal]: + for ordinance in self.lds_ord_list: if ordinance.place in handle_list: ordinance.place = None @@ -271,7 +270,7 @@ class Person(PrimaryObject,SourceNote, new_list.append(item) self.parent_family_list = new_list elif classname == 'Place': - for ordinance in [self.lds_bapt,self.lds_endow,self.lds_seal]: + for ordinance in self.lds_ord_list: if ordinance.place == old_handle: ordinance.place = new_handle @@ -291,7 +290,7 @@ class Person(PrimaryObject,SourceNote, @return: Returns the list of child objects that may carry textual data. @rtype: list """ - check_list = [self.lds_bapt,self.lds_endow,self.lds_seal,self.note] + check_list = self.lds_ord_list + [self.note] add_list = [item for item in check_list if item] return [self.primary_name] + self.media_list + \ self.alternate_names + self.address_list + \ @@ -305,11 +304,9 @@ class Person(PrimaryObject,SourceNote, @return: Returns the list of child secondary child objects that may refer sources. @rtype: list """ - lds_list = [self.lds_bapt,self.lds_endow,self.lds_seal] - lds_check_list = [item for item in lds_list if item] return [self.primary_name] + self.media_list + \ self.alternate_names + self.address_list + \ - self.attribute_list + lds_check_list + self.attribute_list + self.lds_ord_list def get_referenced_handles(self): """ @@ -825,63 +822,3 @@ class Person(PrimaryObject,SourceNote, return None else: return self.parent_family_list[0][0] - - def set_lds_baptism(self,lds_ord): - """ - Sets the LDS Baptism ordinance. An ordinance can be removed - by assigning to None. - - @param lds_ord: L{LdsOrd} to assign as the LDS Baptism ordinance. - @type lds_ord: L{LdsOrd} - """ - self.lds_bapt = lds_ord - - def get_lds_baptism(self): - """ - Returns the LDS Baptism ordinance. - - @returns: returns the L{LdsOrd} instance assigned as the LDS - Baptism ordinance, or None if no ordinance has been assigned. - @rtype: L{LdsOrd} - """ - return self.lds_bapt - - def set_lds_endowment(self,lds_ord): - """ - Sets the LDS Endowment ordinance. An ordinance can be removed - by assigning to None. - - @param lds_ord: L{LdsOrd} to assign as the LDS Endowment ordinance. - @type lds_ord: L{LdsOrd} - """ - self.lds_endow = lds_ord - - def get_lds_endowment(self): - """ - Returns the LDS Endowment ordinance. - - @returns: returns the L{LdsOrd} instance assigned as the LDS - Endowment ordinance, or None if no ordinance has been assigned. - @rtype: L{LdsOrd} - """ - return self.lds_endow - - def set_lds_sealing(self,lds_ord): - """ - Sets the LDS Sealing ordinance. An ordinance can be removed - by assigning to None. - - @param lds_ord: L{LdsOrd} to assign as the LDS Sealing ordinance. - @type lds_ord: L{LdsOrd} - """ - self.lds_seal = lds_ord - - def get_lds_sealing(self): - """ - Returns the LDS Sealing ordinance. - - @returns: returns the L{LdsOrd} instance assigned as the LDS - Sealing ordinance, or None if no ordinance has been assigned. - @rtype: L{LdsOrd} - """ - return self.lds_seal diff --git a/gramps2/src/glade/gramps.glade b/gramps2/src/glade/gramps.glade index 5cd7f5392..ed1e168b1 100644 --- a/gramps2/src/glade/gramps.glade +++ b/gramps2/src/glade/gramps.glade @@ -15283,7 +15283,7 @@ You should select parents before adding any new information. If you select paren - + True GTK_WINDOW_TOPLEVEL @@ -15315,7 +15315,7 @@ You should select parents before adding any new information. If you select paren GTK_BUTTONBOX_END - + True True True @@ -15329,7 +15329,7 @@ You should select parents before adding any new information. If you select paren - + True Accept changes and close window True @@ -15345,7 +15345,7 @@ You should select parents before adding any new information. If you select paren - + True True True @@ -15367,13 +15367,13 @@ You should select parents before adding any new information. If you select paren - + True False 0 - + True False @@ -15401,7 +15401,7 @@ You should select parents before adding any new information. If you select paren 12 True - 4 + 5 3 False 6 @@ -15420,6 +15420,7 @@ You should select parents before adding any new information. If you select paren 0.5 0 0 + date PANGO_ELLIPSIZE_NONE -1 False @@ -15448,6 +15449,7 @@ You should select parents before adding any new information. If you select paren 0.5 0 0 + place PANGO_ELLIPSIZE_NONE -1 False @@ -15464,7 +15466,7 @@ You should select parents before adding any new information. If you select paren - + True True True @@ -15486,7 +15488,7 @@ You should select parents before adding any new information. If you select paren - + True True True @@ -15507,7 +15509,7 @@ You should select parents before adding any new information. If you select paren - + True True GTK_RELIEF_NONE @@ -15538,7 +15540,7 @@ You should select parents before adding any new information. If you select paren - + True True GTK_RELIEF_NONE @@ -15621,7 +15623,7 @@ You should select parents before adding any new information. If you select paren - + True False True @@ -15637,7 +15639,7 @@ You should select parents before adding any new information. If you select paren - + True False True @@ -15651,6 +15653,88 @@ You should select parents before adding any new information. If you select paren fill + + + + Parents: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + GTK_RELIEF_NONE + True + + + + True + gtk-index + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 4 + 5 + fill + + + 0 diff --git a/gramps2/src/lds.py b/gramps2/src/lds.py index 198c73c06..45d898748 100644 --- a/gramps2/src/lds.py +++ b/gramps2/src/lds.py @@ -42,7 +42,7 @@ from TransUtils import sgettext as _ #Last update: 1/12/02 # -lds_temple_codes = { +temple_codes = { "Aba, Nigeria" : "ABA", #1 Added "Accra, Ghana" : "ACCRA", #2 Added "Adelaide, Australia" : "ADELA", #3 Added @@ -180,9 +180,16 @@ lds_temple_codes = { } -lds_temple_to_abrev = {} -for (name,abbr) in lds_temple_codes.iteritems(): - lds_temple_to_abrev[abbr] = name +temple_to_abrev = {} +for (name,abbr) in temple_codes.iteritems(): + temple_to_abrev[abbr] = name + +ord_type = { + 0 : _('Baptism'), + 1 : _('Endowment'), + 2 : _('Sealed to Parents'), + 3 : _('Sealed to Spouse'), + } status = { "BIC" : 1, "CANCELED" : 1, "CHILD" : 1,