18
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
#
20
20
21
+ #------------------------------------------------------------------------
22
+ #
23
+ # Gramps modules
24
+ #
25
+ #------------------------------------------------------------------------
21
26
from gramps .gen .datehandler import displayer as date_displayer
27
+ from gramps .gen .db import DbTxn
22
28
from gramps .gen .display .name import displayer as name_displayer
23
29
from gramps .gen .lib import (Date , Event , EventType , EventRef , EventRoleType ,
24
30
Person )
25
31
32
+ #------------------------------------------------------------------------
33
+ #
34
+ # Gramplet modules
35
+ #
36
+ #------------------------------------------------------------------------
26
37
from actionbase import ActionBase , represents_int
27
38
28
39
#------------------------------------------------------------------------
@@ -54,12 +65,14 @@ def populate_model(self, db, citation, form_event, model):
54
65
for attr in event_ref .get_attribute_list ():
55
66
if (attr .get_type () == "Name" ): # Form specific _attribute name
56
67
model .append (parent , (name_displayer .display (person ), attr .get_value (),
57
- lambda db , trans , citation_handle = citation .handle , person_handle = person .handle : PrimaryNameCitation .command (db , trans , citation_handle , person_handle )))
68
+ lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle : PrimaryNameCitation .command (dbstate , uistate , track , citation_handle , person_handle )))
58
69
59
- def command (db , trans , citation_handle , person_handle ):
70
+ def command (dbstate , uistate , track , citation_handle , person_handle ):
71
+ db = dbstate .db
60
72
person = db .get_person_from_handle (person_handle )
61
73
person .get_primary_name ().add_citation (citation_handle )
62
- db .commit_person (person , trans )
74
+ with DbTxn (_ ("Add Person (%s)" ) % name_displayer .display (person ), db ) as trans :
75
+ db .commit_person (person , trans )
63
76
64
77
class BirthEvent (ActionBase ):
65
78
def __init__ (self ):
@@ -97,7 +110,7 @@ def populate_model(self, db, citation, form_event, model):
97
110
birth_date .set_quality (Date .QUAL_CALCULATED )
98
111
99
112
model .append (parent , (name_displayer .display (person ), date_displayer .display (birth_date ),
100
- lambda db , trans , citation_handle = citation .handle , person_handle = person .handle , birth_date_ = birth_date : ActionBase .add_event_to_person (db , trans , person_handle , EventType .BIRTH , birth_date_ , None , citation_handle , EventRoleType .PRIMARY )))
113
+ lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle , birth_date_ = birth_date : ActionBase .add_event_to_person (dbstate , uistate , track , person_handle , EventType .BIRTH , birth_date_ , None , citation_handle , EventRoleType .PRIMARY )))
101
114
102
115
class OccupationEvent (ActionBase ):
103
116
def __init__ (self ):
@@ -117,4 +130,4 @@ def populate_model(self, db, citation, form_event, model):
117
130
occupation = attr .get_value ()
118
131
if (occupation ) :
119
132
model .append (parent , (name_displayer .display (person ), occupation ,
120
- lambda db , trans , citation_handle = citation .handle , person_handle = person .handle , occupation_ = occupation : ActionBase .add_event_to_person (db , trans , person_handle , EventType .OCCUPATION , form_event .get_date_object (), occupation_ , citation_handle , EventRoleType .PRIMARY )))
133
+ lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle , occupation_ = occupation : ActionBase .add_event_to_person (dbstate , uistate , track , person_handle , EventType .OCCUPATION , form_event .get_date_object (), occupation_ , citation_handle , EventRoleType .PRIMARY )))
0 commit comments