18
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
#
20
20
21
- #------------------------------------------------------------------------
21
+ # ------------------------------------------------------------------------
22
22
#
23
23
# Gramps modules
24
24
#
25
- #------------------------------------------------------------------------
25
+ # ------------------------------------------------------------------------
26
26
from gramps .gen .datehandler import displayer as date_displayer
27
27
from gramps .gen .db import DbTxn
28
28
from gramps .gen .display .name import displayer as name_displayer
31
31
Name , Person )
32
32
from gramps .gen .utils .db import get_participant_from_event
33
33
34
- #------------------------------------------------------------------------
34
+ # ------------------------------------------------------------------------
35
35
#
36
36
# Gramplet modules
37
37
#
38
- #------------------------------------------------------------------------
38
+ # ------------------------------------------------------------------------
39
39
import actionutils
40
40
41
- #------------------------------------------------------------------------
41
+ # ------------------------------------------------------------------------
42
42
#
43
43
# Internationalisation
44
44
#
45
- #------------------------------------------------------------------------
45
+ # ------------------------------------------------------------------------
46
46
from gramps .gen .const import GRAMPS_LOCALE as glocale
47
47
try :
48
48
_trans = glocale .get_addon_translator (__file__ )
51
51
52
52
_ = _trans .gettext
53
53
54
+
54
55
def get_actions (dbstate , citation , form_event ):
55
56
"""
56
57
return a list of all actions that this module can provide for the given citation and form
57
58
each list entry is a string, describing the action category, and a list of actions that can be performed.
58
59
"""
59
60
actions = []
60
- actions .append (PrimaryNameCitation .get_actions (dbstate , citation , form_event ))
61
+ actions .append (PrimaryNameCitation .get_actions (
62
+ dbstate , citation , form_event ))
61
63
actions .append (AlternateName .get_actions (dbstate , citation , form_event ))
62
64
actions .append (BirthEvent .get_actions (dbstate , citation , form_event ))
63
65
actions .append (OccupationEvent .get_actions (dbstate , citation , form_event ))
64
66
actions .append (ResidenceEvent .get_actions (dbstate , citation , form_event ))
65
67
return actions
66
68
69
+
67
70
class PrimaryNameCitation :
68
71
@staticmethod
69
72
def get_actions (dbstate , citation , form_event ):
70
73
db = dbstate .db
71
74
actions = []
72
75
for (person , attr ) in actionutils .get_form_person_attr (db , form_event .get_handle (), 'Name' ):
73
76
actions .append ((name_displayer .display (person ), attr .get_value (),
74
- lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle : PrimaryNameCitation .command (dbstate , uistate , track , citation_handle , person_handle )))
77
+ lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle : PrimaryNameCitation .command (dbstate , uistate , track , citation_handle , person_handle )))
75
78
return (_ ("Add Primary Name citation" ), actions )
76
79
77
80
@staticmethod
@@ -82,6 +85,7 @@ def command(dbstate, uistate, track, citation_handle, person_handle):
82
85
with DbTxn (_ ("Add Person ({name})" ).format (name = name_displayer .display (person )), db ) as trans :
83
86
db .commit_person (person , trans )
84
87
88
+
85
89
class AlternateName :
86
90
@staticmethod
87
91
def get_actions (dbstate , citation , form_event ):
@@ -93,7 +97,7 @@ def get_actions(dbstate, citation, form_event):
93
97
alternate .add_citation (citation .handle )
94
98
detail = _ ('Given Name: {name}' ).format (name = attr .get_value ())
95
99
actions .append ((name_displayer .display (person ), detail ,
96
- lambda dbstate , uistate , track , person_handle = person .handle , alternate_ = alternate : AlternateName .command (dbstate , uistate , track , person_handle , alternate_ )))
100
+ lambda dbstate , uistate , track , person_handle = person .handle , alternate_ = alternate : AlternateName .command (dbstate , uistate , track , person_handle , alternate_ )))
97
101
return (_ ("Add alternate name" ), actions )
98
102
99
103
@staticmethod
@@ -104,6 +108,7 @@ def command(dbstate, uistate, track, person_handle, alternate):
104
108
with DbTxn (_ ("Add Person ({name})" ).format (name = name_displayer .display (person )), db ) as trans :
105
109
db .commit_person (person , trans )
106
110
111
+
107
112
class BirthEvent :
108
113
@staticmethod
109
114
def get_actions (dbstate , citation , form_event ):
@@ -126,26 +131,31 @@ def get_actions(dbstate, citation, form_event):
126
131
elif not birth_date .is_compound ():
127
132
# in theory, birth_date will never be compound since 1841 census date was 1841-06-06. Let's handle it anyway.
128
133
# create a compound range spanning the possible birth years
129
- birth_range = (birth_date - 5 ).get_dmy () + (False ,) + birth_date .get_dmy () + (False ,)
130
- birth_date .set (Date .QUAL_NONE , Date .MOD_RANGE , birth_date .get_calendar (), birth_range , newyear = birth_date .get_new_year ())
134
+ birth_range = (birth_date - 5 ).get_dmy () + \
135
+ (False ,) + birth_date .get_dmy () + (False ,)
136
+ birth_date .set (Date .QUAL_NONE , Date .MOD_RANGE , birth_date .get_calendar (
137
+ ), birth_range , newyear = birth_date .get_new_year ())
131
138
birth_date .set_quality (Date .QUAL_CALCULATED )
132
- detail = _ ('Age: {age}\n Date: {date}' ).format (age = age_string , date = date_displayer .display (birth_date ))
139
+ detail = _ ('Age: {age}\n Date: {date}' ).format (
140
+ age = age_string , date = date_displayer .display (birth_date ))
133
141
actions .append ((name_displayer .display (person ), detail ,
134
- lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle , birth_date_ = birth_date : actionutils .add_event_to_person (dbstate , uistate , track , person_handle , EventType .BIRTH , birth_date_ , None , citation_handle , EventRoleType .PRIMARY )))
142
+ lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle , birth_date_ = birth_date : actionutils .add_event_to_person (dbstate , uistate , track , person_handle , EventType .BIRTH , birth_date_ , None , citation_handle , EventRoleType .PRIMARY )))
135
143
return (_ ("Add Birth event" ), actions )
136
144
145
+
137
146
class OccupationEvent :
138
147
@staticmethod
139
148
def get_actions (dbstate , citation , form_event ):
140
149
db = dbstate .db
141
150
actions = []
142
151
for (person , attr ) in actionutils .get_form_person_attr (db , form_event .get_handle (), 'Occupation' ):
143
152
occupation = attr .get_value ()
144
- if (occupation ) :
153
+ if (occupation ):
145
154
actions .append ((name_displayer .display (person ), _ ('Description: {occupation}' ).format (occupation = occupation ),
146
- lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle , occupation_ = occupation : actionutils .add_event_to_person (dbstate , uistate , track , person_handle , EventType .OCCUPATION , form_event .get_date_object (), occupation_ , citation_handle , EventRoleType .PRIMARY )))
155
+ lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle , occupation_ = occupation : actionutils .add_event_to_person (dbstate , uistate , track , person_handle , EventType .OCCUPATION , form_event .get_date_object (), occupation_ , citation_handle , EventRoleType .PRIMARY )))
147
156
return (_ ("Add Occupation event" ), actions )
148
157
158
+
149
159
class ResidenceEvent :
150
160
@staticmethod
151
161
def get_actions (dbstate , citation , form_event ):
@@ -162,10 +172,11 @@ def get_actions(dbstate, citation, form_event):
162
172
if people :
163
173
detail = None
164
174
if form_event .get_place_handle ():
165
- place = place_displayer .display (db , db .get_place_from_handle (form_event .get_place_handle ()))
175
+ place = place_displayer .display (
176
+ db , db .get_place_from_handle (form_event .get_place_handle ()))
166
177
detail = _ ('Place: {place}' ).format (place = place )
167
178
actions .append ((get_participant_from_event (db , form_event .get_handle ()), detail ,
168
- lambda dbstate , uistate , track , citation_handle = citation .handle , people_handles = people : ResidenceEvent .command (dbstate , uistate , track , citation_handle , form_event .get_date_object (), form_event .get_place_handle (), people_handles )))
179
+ lambda dbstate , uistate , track , citation_handle = citation .handle , people_handles = people : ResidenceEvent .command (dbstate , uistate , track , citation_handle , form_event .get_date_object (), form_event .get_place_handle (), people_handles )))
169
180
return (_ ("Add Residence event" ), actions )
170
181
171
182
@staticmethod
0 commit comments