Package gen :: Package lib :: Module ldsord
[frames] | no frames]

Source Code for Module gen.lib.ldsord

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2000-2007  Donald N. Allingham 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 19  # 
 20   
 21  # $Id: ldsord.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  LDS Ordinance class for GRAMPS. 
 25  """ 
 26   
 27  #------------------------------------------------------------------------- 
 28  # 
 29  # Python modules 
 30  # 
 31  #------------------------------------------------------------------------- 
 32  from gettext import gettext as _ 
 33  from warnings import warn 
 34   
 35  #------------------------------------------------------------------------- 
 36  # 
 37  # GRAMPS modules 
 38  # 
 39  #------------------------------------------------------------------------- 
 40  from gen.lib.secondaryobj import SecondaryObject 
 41  from gen.lib.srcbase import SourceBase 
 42  from gen.lib.notebase import NoteBase 
 43  from gen.lib.datebase import DateBase 
 44  from gen.lib.placebase import PlaceBase 
 45  from gen.lib.privacybase import PrivacyBase 
 46   
 47  #------------------------------------------------------------------------- 
 48  # 
 49  # LDS Ordinance class 
 50  # 
 51  #------------------------------------------------------------------------- 
52 -class LdsOrd(SecondaryObject, SourceBase, NoteBase, 53 DateBase, PlaceBase, PrivacyBase):
54 """ 55 Class that contains information about LDS Ordinances. 56 57 LDS ordinances are similar to events, but have very specific additional 58 information related to data collected by the Church of Jesus Christ 59 of Latter Day Saints (Mormon church). The LDS church is the largest 60 source of genealogical information in the United States. 61 """ 62 63 BAPTISM = 0 64 ENDOWMENT = 1 65 SEAL_TO_PARENTS = 2 66 SEAL_TO_SPOUSE = 3 67 CONFIRMATION = 4 68 69 DEFAULT_TYPE = BAPTISM 70 71 72 STATUS_NONE = 0 73 STATUS_BIC = 1 74 STATUS_CANCELED = 2 75 STATUS_CHILD = 3 76 STATUS_CLEARED = 4 77 STATUS_COMPLETED = 5 78 STATUS_DNS = 6 79 STATUS_INFANT = 7 80 STATUS_PRE_1970 = 8 81 STATUS_QUALIFIED = 9 82 STATUS_DNS_CAN = 10 83 STATUS_STILLBORN = 11 84 STATUS_SUBMITTED = 12 85 STATUS_UNCLEARED = 13 86 87 DEFAULT_STATUS = STATUS_NONE 88 89 90 _TYPE_MAP = [ 91 (BAPTISM, _('Baptism'), 'baptism'), 92 (ENDOWMENT, _('Endowment'), 'endowment'), 93 (CONFIRMATION, _('Confirmation'), 'confirmation'), 94 (SEAL_TO_PARENTS, _('Sealed to Parents'), 'sealed_to_parents'), 95 (SEAL_TO_SPOUSE, _('Sealed to Spouse'), 'sealed_to_spouse' ), 96 ] 97 98 _STATUS_MAP = [ 99 (STATUS_NONE, _("<No Status>"), ""), 100 (STATUS_BIC, _("BIC"), "BIC"), 101 (STATUS_CANCELED, _("Canceled"), "Canceled"), 102 (STATUS_CHILD, _("Child"), "Child"), 103 (STATUS_CLEARED, _("Cleared"), "Cleared"), 104 (STATUS_COMPLETED, _("Completed"), "Completed"), 105 (STATUS_DNS, _("DNS"), "DNS"), 106 (STATUS_INFANT, _("Infant"), "Infant"), 107 (STATUS_PRE_1970, _("Pre-1970"), "Pre-1970"), 108 (STATUS_QUALIFIED, _("Qualified"), "Qualified"), 109 (STATUS_DNS_CAN, _("DNS/CAN"), "DNS/CAN"), 110 (STATUS_STILLBORN, _("Stillborn"), "Stillborn"), 111 (STATUS_SUBMITTED, _("Submitted"), "Submitted"), 112 (STATUS_UNCLEARED, _("Uncleared"), "Uncleared"), 113 ] 114
115 - def __init__(self, source=None):
116 """Create a LDS Ordinance instance.""" 117 SourceBase.__init__(self, source) 118 NoteBase.__init__(self, source) 119 DateBase.__init__(self, source) 120 PlaceBase.__init__(self, source) 121 PrivacyBase.__init__(self, source) 122 123 if source: 124 self.type = source.type 125 self.famc = source.famc 126 self.temple = source.temple 127 self.status = source.status 128 else: 129 self.type = LdsOrd.DEFAULT_TYPE 130 self.famc = None 131 self.temple = "" 132 self.status = LdsOrd.DEFAULT_STATUS
133
134 - def serialize(self):
135 """ 136 Convert the object to a serialized tuple of data. 137 """ 138 return (SourceBase.serialize(self), 139 NoteBase.serialize(self), 140 DateBase.serialize(self), 141 self.type, self.place, 142 self.famc, self.temple, self.status, self.private)
143
144 - def unserialize(self, data):
145 """ 146 Convert a serialized tuple of data to an object. 147 """ 148 (source_list, note_list, date, self.type, self.place, 149 self.famc, self.temple, self.status, self.private) = data 150 SourceBase.unserialize(self, source_list) 151 NoteBase.unserialize(self, note_list) 152 DateBase.unserialize(self, date) 153 return self
154
155 - def get_text_data_list(self):
156 """ 157 Return the list of all textual attributes of the object. 158 159 @return: Returns the list of all textual attributes of the object. 160 @rtype: list 161 """ 162 return [self.temple]
163 #return [self.temple,self.get_date()] 164
165 - def get_text_data_child_list(self):
166 """ 167 Return the list of child objects that may carry textual data. 168 169 @return: Returns the list of child objects that may carry textual data. 170 @rtype: list 171 """ 172 return self.source_list
173
174 - def get_note_child_list(self):
175 """ 176 Return the list of child secondary objects that may refer notes. 177 178 @return: Returns the list of child secondary child objects that may 179 refer notes. 180 @rtype: list 181 """ 182 return self.source_list
183
184 - def get_referenced_handles(self):
185 """ 186 Return the list of (classname, handle) tuples for all directly 187 referenced primary objects. 188 189 @return: List of (classname, handle) tuples for referenced objects. 190 @rtype: list 191 """ 192 ret = self.get_referenced_note_handles() 193 if self.place: 194 ret += [('Place', self.place)] 195 return ret
196
197 - def get_handle_referents(self):
198 """ 199 Return the list of child objects which may, directly or through 200 their children, reference primary objects. 201 202 @return: Returns the list of objects refereincing primary objects. 203 @rtype: list 204 """ 205 return self.source_list
206
207 - def get_type(self):
208 """ 209 Return the type of the Event. 210 211 @return: Type of the Event 212 @rtype: tuple 213 """ 214 return self.type
215
216 - def set_type(self, ord_type):
217 """ 218 Set the type of the LdsOrd to the passed (int,str) tuple. 219 220 @param ord_type: Type to assign to the LdsOrd 221 @type ord_type: tuple 222 """ 223 self.type = ord_type
224
225 - def set_family_handle(self, family):
226 """Set the Family database handle associated with the LDS ordinance.""" 227 self.famc = family
228
229 - def get_family_handle(self):
230 """Get the Family database handle associated with the LDS ordinance.""" 231 return self.famc
232
233 - def set_status(self, val):
234 """ 235 Set the status of the LDS ordinance. 236 237 The status is a text string that matches a predefined set of strings. 238 """ 239 self.status = val
240
241 - def get_status(self):
242 """Get the status of the LDS ordinance.""" 243 return self.status
244
245 - def set_temple(self, temple):
246 """Set the temple assocated with the ordinance.""" 247 self.temple = temple
248
249 - def get_temple(self):
250 """Get the temple assocated with the ordinance.""" 251 return self.temple
252
253 - def is_empty(self):
254 """Return 1 if the ordinance is actually empty.""" 255 if (self.famc or 256 (self.date and not self.date.is_empty()) or 257 self.temple or 258 self.status or 259 self.place): 260 return False 261 else: 262 return True
263
264 - def are_equal(self, other):
265 """Return 1 if the specified ordinance is the same as the instance.""" 266 warn( "Use is_equal instead are_equal", DeprecationWarning, 2) 267 return self.is_equal(other)
268
269 - def type2xml(self):
270 """ 271 Return type-representing string suitable for XML. 272 """ 273 for item in LdsOrd._TYPE_MAP: 274 if item[0] == self.type: 275 return item[2] 276 return ""
277
278 - def type2str(self):
279 """ 280 Return type-representing string suitable for UI (translated). 281 """ 282 for item in LdsOrd._TYPE_MAP: 283 if item[0] == self.type: 284 return item[1] 285 return ""
286
287 - def set_type_from_xml(self, xml_str):
288 """ 289 Set type based on a given string from XML. 290 291 Return boolean on success. 292 """ 293 for item in LdsOrd._TYPE_MAP: 294 if item[2] == xml_str: 295 self.type = item[0] 296 return True 297 return False
298
299 - def status2xml(self):
300 """ 301 Return status-representing string suitable for XML. 302 """ 303 for item in LdsOrd._STATUS_MAP: 304 if item[0] == self.status: 305 return item[2] 306 return ""
307
308 - def status2str(self):
309 """ 310 Return status-representing string suitable for UI (translated). 311 """ 312 for item in LdsOrd._STATUS_MAP: 313 if item[0] == self.status: 314 return item[1] 315 return ""
316
317 - def set_status_from_xml(self, xml_str):
318 """ 319 Set status based on a given string from XML. 320 321 Return boolean on success. 322 """ 323 for item in LdsOrd._STATUS_MAP: 324 if item[2] == xml_str: 325 self.status = item[0] 326 return True 327 return False
328