|
28 | 28 | from gramps.gen.display.name import displayer as name_displayer
|
29 | 29 | from gramps.gen.display.place import displayer as place_displayer
|
30 | 30 | from gramps.gen.lib import (Date, Event, EventType, EventRef, EventRoleType,
|
31 |
| - Person) |
| 31 | + Name, Person) |
32 | 32 | from gramps.gen.utils.db import get_participant_from_event
|
33 | 33 |
|
34 | 34 | #------------------------------------------------------------------------
|
@@ -70,6 +70,28 @@ def command(dbstate, uistate, track, citation_handle, person_handle):
|
70 | 70 | with DbTxn(_("Add Person (%s)") % name_displayer.display(person), db) as trans:
|
71 | 71 | db.commit_person(person, trans)
|
72 | 72 |
|
| 73 | +class AlternateName(ActionBase): |
| 74 | + def __init__(self): |
| 75 | + ActionBase.__init__(self) |
| 76 | + |
| 77 | + def get_actions(self, dbstate, citation, form_event): |
| 78 | + db = dbstate.db |
| 79 | + actions = [] |
| 80 | + for (person, attr) in ActionBase.get_form_person_attr(db, form_event.get_handle(), 'Name'): |
| 81 | + alternate = Name() |
| 82 | + alternate.set_first_name(attr.get_value()) |
| 83 | + alternate.add_citation(citation.handle) |
| 84 | + actions.append((name_displayer.display(person), attr.get_value(), |
| 85 | + lambda dbstate, uistate, track, person_handle = person.handle, alternate_ = alternate: AlternateName.command(dbstate, uistate, track, person_handle, alternate_))) |
| 86 | + return (_("Add alternate name"), actions) |
| 87 | + |
| 88 | + def command(dbstate, uistate, track, person_handle, alternate): |
| 89 | + db = dbstate.db |
| 90 | + person = db.get_person_from_handle(person_handle) |
| 91 | + person.add_alternate_name(alternate) |
| 92 | + with DbTxn(_("Add Person (%s)") % name_displayer.display(person), db) as trans: |
| 93 | + db.commit_person(person, trans) |
| 94 | + |
73 | 95 | class BirthEvent(ActionBase):
|
74 | 96 | def __init__(self):
|
75 | 97 | ActionBase.__init__(self)
|
|
0 commit comments