Refinements to give more feedback on probably alive; use CAUSE_DEATH as additional evidence for death; date span shows (unknown) for invalid differences.

svn: r11556
This commit is contained in:
Doug Blank 2009-01-01 00:58:18 +00:00
parent dad8af1cd4
commit dc2c438231
4 changed files with 23 additions and 12 deletions

View File

@ -46,7 +46,7 @@ import gtk
import gen.lib import gen.lib
import PageView import PageView
from BasicUtils import name_displayer from BasicUtils import name_displayer
from Utils import media_path_full from Utils import media_path_full, probably_alive
import DateHandler import DateHandler
import ThumbNails import ThumbNails
import Config import Config
@ -584,10 +584,16 @@ class RelationshipView(PageView.PersonNavView):
showed_death = True showed_death = True
if not showed_death: if not showed_death:
age = gen.lib.date.Today() - birth_date age = gen.lib.date.Today() - birth_date
subtbl.attach(widgets.BasicLabel("%s:" % death_title), if probably_alive(person, self.dbstate.db):
subtbl.attach(widgets.BasicLabel("%s:" % _("Alive")),
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0) 1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
subtbl.attach(widgets.BasicLabel("(%s)" % age), subtbl.attach(widgets.BasicLabel("(%s)" % age),
2, 3, 2, 3, yoptions=0) 2, 3, 2, 3, yoptions=0)
else:
subtbl.attach(widgets.BasicLabel("%s:" % _("Death")),
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
subtbl.attach(widgets.BasicLabel("%s (%s)" % (_("unknown"), age)),
2, 3, 2, 3, yoptions=0)
showed_death = True showed_death = True
if not showed_death: if not showed_death:

View File

@ -600,7 +600,7 @@ class PeopleModel(gtk.GenericTreeModel):
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 = DateHandler.get_date(event) date_str = DateHandler.get_date(event)
if (etype in [EventType.BURIAL, EventType.CREMATION] if (etype in [EventType.BURIAL, EventType.CREMATION, EventType.CAUSE_DEATH]
and er.get_role() == EventRoleType.PRIMARY and er.get_role() == EventRoleType.PRIMARY
and date_str): and date_str):
retval = "<i>%s</i>" % cgi.escape(date_str) retval = "<i>%s</i>" % cgi.escape(date_str)
@ -667,8 +667,8 @@ class PeopleModel(gtk.GenericTreeModel):
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 in [EventType.BURIAL, EventType.CREMATION, EventType.CAUSE_DEATH]
and er.get_role() == EventRoleType.PRIMARY: and er.get_role() == EventRoleType.PRIMARY):
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
if place_handle: if place_handle:
place = self.db.get_place_from_handle(place_handle) place = self.db.get_place_from_handle(place_handle)

View File

@ -2785,8 +2785,10 @@ def get_death_or_fallback(database, person):
# now search the event list for fallbacks # now search the event list for fallbacks
for event_ref in person.get_primary_event_ref_list(): for event_ref in person.get_primary_event_ref_list():
event = database.get_event_from_handle(event_ref.ref) event = database.get_event_from_handle(event_ref.ref)
if event.type.value in [EventType.BURIAL, EventType.CREMATION] \ if (event.type.value in [EventType.BURIAL,
and event_ref.role.value == EventRoleType.PRIMARY: EventType.CREMATION,
EventType.CAUSE_DEATH]
and event_ref.role.value == EventRoleType.PRIMARY):
return event return event
return None return None

View File

@ -72,7 +72,7 @@ class DateError(Exception):
class Span: class Span:
""" Class used in date differences """ """ Class used in date differences """
def __init__(self, *diff_tuple): def __init__(self, *diff_tuple):
self.diff_tuple = diff_tuple self.diff_tuple = tuple(diff_tuple)
def __getitem__(self, pos): def __getitem__(self, pos):
return self.diff_tuple[pos] return self.diff_tuple[pos]
@ -81,6 +81,7 @@ class Span:
return True return True
def __repr__(self): def __repr__(self):
if self.diff_tuple == (-1, -1, -1): return _("unknown")
retval = "" retval = ""
if self.diff_tuple[0] != 0: if self.diff_tuple[0] != 0:
retval += (_("%d years") % self.diff_tuple[0]) retval += (_("%d years") % self.diff_tuple[0])
@ -358,6 +359,8 @@ class Date:
date1 = date1.to_calendar("gregorian") date1 = date1.to_calendar("gregorian")
if date2.calendar != Date.CAL_GREGORIAN: if date2.calendar != Date.CAL_GREGORIAN:
date2 = date2.to_calendar("gregorian") date2 = date2.to_calendar("gregorian")
if date1.sortval == 0 or date2.sortval == 0:
return Span(-1, -1, -1)
d1 = [i or 1 for i in date1.get_ymd()] d1 = [i or 1 for i in date1.get_ymd()]
d2 = [i or 1 for i in date2.get_ymd()] d2 = [i or 1 for i in date2.get_ymd()]
if d1 < d2: if d1 < d2: