1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """
24 LDS Ordinance class for GRAMPS.
25 """
26
27
28
29
30
31
32 from gettext import gettext as _
33 from warnings import warn
34
35
36
37
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
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
133
143
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
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
164
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
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
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
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
208 """
209 Return the type of the Event.
210
211 @return: Type of the Event
212 @rtype: tuple
213 """
214 return self.type
215
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
226 """Set the Family database handle associated with the LDS ordinance."""
227 self.famc = family
228
230 """Get the Family database handle associated with the LDS ordinance."""
231 return self.famc
232
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
242 """Get the status of the LDS ordinance."""
243 return self.status
244
246 """Set the temple assocated with the ordinance."""
247 self.temple = temple
248
250 """Get the temple assocated with the ordinance."""
251 return self.temple
252
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
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
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
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
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
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
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
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