@@ -73,7 +73,7 @@ def get_actions(dbstate, citation, form_event):
73
73
db = dbstate .db
74
74
actions = []
75
75
for (person , attr ) in actionutils .get_form_person_attr (db , form_event .get_handle (), 'Name' ):
76
- actions .append ((name_displayer .display (person ), attr .get_value (),
76
+ actions .append ((name_displayer .display (person ), attr .get_value (), actionutils . CANNOT_EDIT_DETAIL ,
77
77
lambda dbstate , uistate , track , citation_handle = citation .handle , person_handle = person .handle : PrimaryNameCitation .command (dbstate , uistate , track , citation_handle , person_handle )))
78
78
return (_ ("Add Primary Name citation" ), actions )
79
79
@@ -96,7 +96,7 @@ def get_actions(dbstate, citation, form_event):
96
96
alternate .set_first_name (attr .get_value ())
97
97
alternate .add_citation (citation .handle )
98
98
detail = _ ('Given Name: {name}' ).format (name = attr .get_value ())
99
- actions .append ((name_displayer .display (person ), detail ,
99
+ actions .append ((name_displayer .display (person ), detail , actionutils . MUST_EDIT_DETAIL ,
100
100
lambda dbstate , uistate , track , person_handle = person .handle , alternate_ = alternate : AlternateName .command (dbstate , uistate , track , person_handle , alternate_ )))
101
101
return (_ ("Add alternate name" ), actions )
102
102
@@ -118,28 +118,32 @@ def get_actions(dbstate, citation, form_event):
118
118
if form_event .get_date_object ():
119
119
for (person , attr ) in actionutils .get_form_person_attr (db , form_event .get_handle (), 'Age' ):
120
120
age_string = attr .get_value ()
121
- if age_string and actionutils .represents_int (age_string ):
122
- age = int (age_string )
123
- if age :
124
- birth_date = form_event .get_date_object () - age
125
- birth_date .make_vague ()
126
- # Age was rounded down to the nearest five years for those aged 15 or over
127
- # In practice this rule was not always followed by enumerators
128
- if age < 15 :
129
- # no adjustment required
130
- birth_date .set_modifier (Date .MOD_ABOUT )
131
- elif not birth_date .is_compound ():
132
- # in theory, birth_date will never be compound since 1841 census date was 1841-06-06. Let's handle it anyway.
133
- # create a compound range spanning the possible birth years
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 ())
138
- birth_date .set_quality (Date .QUAL_CALCULATED )
139
- detail = _ ('Age: {age}\n Date: {date}' ).format (
140
- age = age_string , date = date_displayer .display (birth_date ))
141
- actions .append ((name_displayer .display (person ), detail ,
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 )))
121
+ if age_string :
122
+ birth_date = None
123
+ if actionutils .represents_int (age_string ):
124
+ age = int (age_string )
125
+ if age :
126
+ birth_date = form_event .get_date_object () - age
127
+ birth_date .make_vague ()
128
+ # Age was rounded down to the nearest five years for those aged 15 or over
129
+ # In practice this rule was not always followed by enumerators
130
+ if age < 15 :
131
+ # no adjustment required
132
+ birth_date .set_modifier (Date .MOD_ABOUT )
133
+ elif not birth_date .is_compound ():
134
+ # in theory, birth_date will never be compound since 1841 census date was 1841-06-06. Let's handle it anyway.
135
+ # create a compound range spanning the possible birth years
136
+ birth_range = (birth_date - 5 ).get_dmy () + \
137
+ (False ,) + birth_date .get_dmy () + (False ,)
138
+ birth_date .set (Date .QUAL_NONE , Date .MOD_RANGE , birth_date .get_calendar (
139
+ ), birth_range , newyear = birth_date .get_new_year ())
140
+ birth_date .set_quality (Date .QUAL_CALCULATED )
141
+ detail = _ ('Age: {age}\n Date: {date}' ).format (
142
+ age = age_string , date = date_displayer .display (birth_date ))
143
+ else :
144
+ detail = _ ('Age: {age}' ).format (age = age_string )
145
+ actions .append ((name_displayer .display (person ), detail , actionutils .CAN_EDIT_DETAIL if birth_date else actionutils .MUST_EDIT_DETAIL ,
146
+ 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 )))
143
147
return (_ ("Add Birth event" ), actions )
144
148
145
149
@@ -151,7 +155,7 @@ def get_actions(dbstate, citation, form_event):
151
155
for (person , attr ) in actionutils .get_form_person_attr (db , form_event .get_handle (), 'Occupation' ):
152
156
occupation = attr .get_value ()
153
157
if (occupation ):
154
- actions .append ((name_displayer .display (person ), _ ('Description: {occupation}' ).format (occupation = occupation ),
158
+ actions .append ((name_displayer .display (person ), _ ('Description: {occupation}' ).format (occupation = occupation ), actionutils . CAN_EDIT_DETAIL ,
155
159
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 )))
156
160
return (_ ("Add Occupation event" ), actions )
157
161
@@ -175,7 +179,7 @@ def get_actions(dbstate, citation, form_event):
175
179
place = place_displayer .display (
176
180
db , db .get_place_from_handle (form_event .get_place_handle ()))
177
181
detail = _ ('Place: {place}' ).format (place = place )
178
- actions .append ((get_participant_from_event (db , form_event .get_handle ()), detail ,
182
+ actions .append ((get_participant_from_event (db , form_event .get_handle ()), detail , actionutils . MUST_EDIT_DETAIL ,
179
183
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 )))
180
184
return (_ ("Add Residence event" ), actions )
181
185
0 commit comments