@@ -54,12 +54,14 @@ def __init__(self):
54
54
ActionBase .__init__ (self )
55
55
pass
56
56
57
- def populate_model (self , dbstate , citation , form_event , model ):
57
+ def get_actions (self , dbstate , citation , form_event ):
58
58
db = dbstate .db
59
- parent = model . append ( None , ( _ ( "Add Primary Name citation" ), None , None ))
59
+ actions = []
60
60
for (person , attr ) in ActionBase .get_form_person_attr (db , form_event .get_handle (), 'Name' ):
61
- model .append (parent , (name_displayer .display (person ), attr .get_value (),
61
+ pass
62
+ actions .append ((name_displayer .display (person ), attr .get_value (),
62
63
lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle : PrimaryNameCitation .command (dbstate , uistate , track , citation_handle , person_handle )))
64
+ return (_ ("Add Primary Name citation" ), actions )
63
65
64
66
def command (dbstate , uistate , track , citation_handle , person_handle ):
65
67
db = dbstate .db
@@ -73,11 +75,11 @@ def __init__(self):
73
75
ActionBase .__init__ (self )
74
76
pass
75
77
76
- def populate_model (self , dbstate , citation , form_event , model ):
78
+ def get_actions (self , dbstate , citation , form_event ):
77
79
db = dbstate .db
80
+ actions = []
78
81
# if there is no date on the form, no actions can be performed
79
82
if form_event .get_date_object ():
80
- parent = model .append (None , (_ ("Add Birth event" ), None , None ))
81
83
for (person , attr ) in ActionBase .get_form_person_attr (db , form_event .get_handle (), 'Age' ):
82
84
age_string = attr .get_value ()
83
85
if age_string and represents_int (age_string ):
@@ -97,19 +99,21 @@ def populate_model(self, dbstate, citation, form_event, model):
97
99
birth_date .set (Date .QUAL_NONE , Date .MOD_RANGE , birth_date .get_calendar (), birth_range , newyear = birth_date .get_new_year ())
98
100
birth_date .set_quality (Date .QUAL_CALCULATED )
99
101
100
- model .append (parent , (name_displayer .display (person ), date_displayer .display (birth_date ),
102
+ actions .append ((name_displayer .display (person ), date_displayer .display (birth_date ),
101
103
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 )))
104
+ return (_ ("Add Birth event" ), actions )
102
105
103
106
class OccupationEvent (ActionBase ):
104
107
def __init__ (self ):
105
108
ActionBase .__init__ (self )
106
109
pass
107
110
108
- def populate_model (self , dbstate , citation , form_event , model ):
111
+ def get_actions (self , dbstate , citation , form_event ):
109
112
db = dbstate .db
110
- parent = model . append ( None , ( _ ( 'Add Occupation event' ), None , None ))
113
+ actions = []
111
114
for (person , attr ) in ActionBase .get_form_person_attr (db , form_event .get_handle (), 'Occupation' ):
112
115
occupation = attr .get_value ()
113
116
if (occupation ) :
114
- model .append (parent , (name_displayer .display (person ), occupation ,
115
- 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 )))
117
+ actions .append ((name_displayer .display (person ), occupation ,
118
+ 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 )))
119
+ return (_ ("Add Occupation event" ), actions )
0 commit comments