Add Stillbirth as pre-defined event type

Add Stillbirth as a fallback for both Birth and Death events.
This commit is contained in:
Dave Scheipers 2020-11-09 18:44:12 -05:00 committed by Nick Hall
parent 222bfff175
commit 278c168f9b
2 changed files with 17 additions and 13 deletions

View File

@ -82,6 +82,7 @@ class EventType(GrampsType):
.. attribute DIV_FILING: Divorce Filing .. attribute DIV_FILING: Divorce Filing
.. attribute ANNULMENT: Annulment .. attribute ANNULMENT: Annulment
.. attribute MARR_ALT: Alternate Marriage .. attribute MARR_ALT: Alternate Marriage
.. attribute STILLBIRTH: Stillbirth
""" """
UNKNOWN = -1 UNKNOWN = -1
CUSTOM = 0 CUSTOM = 0
@ -129,13 +130,14 @@ class EventType(GrampsType):
RESIDENCE = 42 RESIDENCE = 42
RETIREMENT = 43 RETIREMENT = 43
WILL = 44 WILL = 44
STILLBIRTH = 45
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh # _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
def _T_(value, context=''): # enable deferred translations def _T_(value, context=''): # enable deferred translations
return "%s\x04%s" % (context, value) if context else value return "%s\x04%s" % (context, value) if context else value
_MENU = [[_T_('Life Events'), _MENU = [[_T_('Life Events'),
[BIRTH, BAPTISM, DEATH, BURIAL, CREMATION, ADOPT]], [BIRTH, BAPTISM, DEATH, STILLBIRTH, BURIAL, CREMATION, ADOPT]],
[_T_('Family'), [_T_('Family'),
[ENGAGEMENT, MARRIAGE, DIVORCE, ANNULMENT, MARR_SETTL, MARR_LIC, [ENGAGEMENT, MARRIAGE, DIVORCE, ANNULMENT, MARR_SETTL, MARR_LIC,
MARR_CONTR, MARR_BANNS, DIV_FILING, MARR_ALT]], MARR_CONTR, MARR_BANNS, DIV_FILING, MARR_ALT]],
@ -205,6 +207,7 @@ class EventType(GrampsType):
(DIV_FILING, _("Divorce Filing"), "Divorce Filing"), (DIV_FILING, _("Divorce Filing"), "Divorce Filing"),
(ANNULMENT, _("Annulment"), "Annulment"), (ANNULMENT, _("Annulment"), "Annulment"),
(MARR_ALT, _("Alternate Marriage"), "Alternate Marriage"), (MARR_ALT, _("Alternate Marriage"), "Alternate Marriage"),
(STILLBIRTH, _("Stillbirth"), "Stillbirth"),
] ]
_ABBREVIATIONS = { _ABBREVIATIONS = {
@ -253,7 +256,8 @@ class EventType(GrampsType):
ENGAGEMENT: _T_("engd.", "Engagement abbreviation"), ENGAGEMENT: _T_("engd.", "Engagement abbreviation"),
DIVORCE: _T_("div.", "Divorce abbreviation"), DIVORCE: _T_("div.", "Divorce abbreviation"),
DIV_FILING: _T_("div.f.", "Divorce Filing abbreviation"), DIV_FILING: _T_("div.f.", "Divorce Filing abbreviation"),
ANNULMENT: _T_("annul.", "Annulment abbreviation") ANNULMENT: _T_("annul.", "Annulment abbreviation"),
STILLBIRTH: _T_("still.", "Stillbirth abbreviation")
} }
def __init__(self, value=None): def __init__(self, value=None):
@ -292,17 +296,20 @@ class EventType(GrampsType):
Returns True if EventType is a birth fallback, False Returns True if EventType is a birth fallback, False
otherwise. otherwise.
""" """
return self.value in [self.CHRISTEN, return self.value in [self.STILLBIRTH,
self.BAPTISM] self.BAPTISM,
self.CHRISTEN]
def is_death_fallback(self): def is_death_fallback(self):
""" """
Returns True if EventType is a death fallback, False Returns True if EventType is a death fallback, False
otherwise. otherwise.
""" """
return self.value in [self.BURIAL, return self.value in [self.STILLBIRTH,
self.BURIAL,
self.CREMATION, self.CREMATION,
self.CAUSE_DEATH] self.CAUSE_DEATH]
def is_marriage(self): def is_marriage(self):
""" """
Returns True if EventType is MARRIAGE, False otherwise. Returns True if EventType is MARRIAGE, False otherwise.

View File

@ -266,7 +266,7 @@ class PeopleBaseModel(BaseModel):
event = self.db.get_event_from_handle(er.ref) event = self.db.get_event_from_handle(er.ref)
etype = event.get_type() etype = event.get_type()
date_str = get_date(event) date_str = get_date(event)
if (etype in [EventType.BAPTISM, EventType.CHRISTEN] if (etype.is_birth_fallback()
and er.get_role() == EventRoleType.PRIMARY and er.get_role() == EventRoleType.PRIMARY
and date_str != ""): and date_str != ""):
if sort_mode: if sort_mode:
@ -323,9 +323,7 @@ class PeopleBaseModel(BaseModel):
event = self.db.get_event_from_handle(er.ref) event = self.db.get_event_from_handle(er.ref)
etype = event.get_type() etype = event.get_type()
date_str = get_date(event) date_str = get_date(event)
if (etype in [EventType.BURIAL, if (etype.is_death_fallback()
EventType.CREMATION,
EventType.CAUSE_DEATH]
and er.get_role() == EventRoleType.PRIMARY and er.get_role() == EventRoleType.PRIMARY
and date_str): and date_str):
if sort_mode: if sort_mode:
@ -367,8 +365,8 @@ class PeopleBaseModel(BaseModel):
er.unserialize(event_ref) er.unserialize(event_ref)
event = self.db.get_event_from_handle(er.ref) event = self.db.get_event_from_handle(er.ref)
etype = event.get_type() etype = event.get_type()
if (etype in [EventType.BAPTISM, EventType.CHRISTEN] and if (etype.is_birth_fallback()
er.get_role() == EventRoleType.PRIMARY): and er.get_role() == EventRoleType.PRIMARY):
place_title = place_displayer.display_event(self.db, event) place_title = place_displayer.display_event(self.db, event)
if place_title: if place_title:
value = "<i>%s</i>" % escape(place_title) value = "<i>%s</i>" % escape(place_title)
@ -407,8 +405,7 @@ class PeopleBaseModel(BaseModel):
er.unserialize(event_ref) er.unserialize(event_ref)
event = self.db.get_event_from_handle(er.ref) event = self.db.get_event_from_handle(er.ref)
etype = event.get_type() etype = event.get_type()
if (etype in [EventType.BURIAL, EventType.CREMATION, if (etype.is_death_fallback()
EventType.CAUSE_DEATH]
and er.get_role() == EventRoleType.PRIMARY): and er.get_role() == EventRoleType.PRIMARY):
place_title = place_displayer.display_event(self.db, event) place_title = place_displayer.display_event(self.db, event)