* src/plugins/WebPage.py: Convert to ids. Call probably_alive

with db as an argument. Move by_date inside the class (needs db).
* src/RelLib.py: Correct probably_alive to ids.


svn: r3003
This commit is contained in:
Alex Roitman 2004-03-11 04:24:03 +00:00
parent d2a9753e1c
commit ef1928e972
3 changed files with 91 additions and 60 deletions

View File

@ -5,7 +5,9 @@
* src/GenericFilter.py: Convert to ids.
* src/plugins/FilterEditor.py: Convert to ids.
* src/plugins/WebPage.py: Convert to ids.
* src/plugins/WebPage.py: Convert to ids. Call probably_alive
with db as an argument. Move by_date inside the class (needs db).
* src/RelLib.py: Correct probably_alive to ids.
2004-03-10 Leonid Mamtchenkov <leonid@leonid.maks.net>
* src/plugins/WebPage.py: Link main photo to the original.

View File

@ -1489,12 +1489,14 @@ class Person(SourceNote):
def get_lds_sealing(self):
return self.lds_seal
def probably_alive(self):
def probably_alive(self,db):
"""Returns true if the person may be alive."""
if not self.death.is_empty ():
if self.death_id:
return 0
if self.birth.get_date() != "":
return not_too_old(self.birth.get_date_object().get_start_date())
if self.birth_id:
birth = db.find_event_from_id(self.birth_id)
if birth.get_date() != "":
return not_too_old(birth.get_date_object().get_start_date())
# Neither birth nor death events are available. Try looking
# for descendants that were born more than a lifespan ago.
@ -1503,17 +1505,23 @@ class Person(SourceNote):
max_generation = 60
max_age_difference = 60
def descendants_too_old (person, years):
for family in person.get_family_id_list():
for child in family.get_child_id_list():
if child.birth.get_date () != "":
d = SingleDate (child.birth.get_date_object ().
for family_id in person.get_family_id_list():
family = db.find_family_from_id(family_id)
for child_id in family.get_child_id_list():
child = db.find_person_from_id(child_id)
if child.birth_id:
child_birth = db.find_event_from_id(child.birth_id)
if child_birth.get_date () != "":
d = SingleDate (child_birth.get_date_object ().
get_start_date ())
d.setYear (d.getYear () - years)
if not not_too_old (d):
return 1
if child.death.get_date () != "":
d = SingleDate (child.death.get_date_object ().
if child.death_id:
child_death = db.find_event_from_id(child.death_id)
if child_death.get_date () != "":
d = SingleDate (child_death.get_date_object ().
get_start_date ())
if not not_too_old (d):
return 1
@ -1526,13 +1534,17 @@ class Person(SourceNote):
# What about their parents?
def parents_too_old (person, age_difference):
family = person.get_main_parents_family_id ()
if family:
for parent in [family.get_father_id (), family.get_mother_id ()]:
if not parent:
family_id = person.get_main_parents_family_id ()
if family_id:
family = db.find_family_from_id(family_id)
for parent_id in [family.get_father_id (), family.get_mother_id ()]:
if not parent_id:
continue
if parent.birth.get_date () != "":
parent = db.find_person_from_id(parent_id)
if parent.birth_id:
parent_birth = db.find_event_from_id(parent.birth_id)
if parent_birth.get_date () != "":
d = SingleDate (parent.birth.get_date_object ().
get_start_date ())
d.setYear (d.getYear () + max_generation +
@ -1540,7 +1552,9 @@ class Person(SourceNote):
if not not_too_old (d):
return 1
if parent.death.get_date () != "":
if parent.death_id:
parent_death = db.find_event_from_id(parent.death_id)
if parent_death.get_date () != "":
d = SingleDate (parent.death.get_date_object ().
get_start_date ())
d.setYear (d.getYear () + age_difference)
@ -1552,20 +1566,26 @@ class Person(SourceNote):
# As a last resort, trying seeing if their spouse's age gives
# any clue.
for family in self.get_family_id_list ():
for spouse in [family.get_father_id (), family.get_mother_id ()]:
if not spouse:
for family_id in self.get_family_id_list ():
family = db.find_family_from_id(family_id)
for spouse_id in [family.get_father_id (), family.get_mother_id ()]:
if not spouse_id:
continue
if spouse == self:
if spouse_id == self.id:
continue
if spouse.birth.get_date () != "":
spouse = db.find_person_from_id(spouse_id)
if spouse.birth_id:
spouse_birth = db.find_event_from_id(spouse.birth_id)
if spouse_birth.get_date () != "":
d = SingleDate (spouse.birth.get_date_object().
get_start_date ())
d.setYear (d.getYear () + max_age_difference)
if not not_too_old (d):
return 0
if spouse.death.get_date () != "":
if spouse.death_id:
spouse_death = db.find_event_from_id(spouse.death_id)
if spouse_death.get_date () != "":
d = SingleDate (spouse.birth.get_date_object().
get_start_date ())
d.setYear (d.getYear () - min_generation)

View File

@ -70,14 +70,6 @@ _month = [
_hline = " " # Everything is underlined, so use blank
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
def by_date(a,b):
return Date.compare_dates(a.get_date_object(),b.get_date_object())
#------------------------------------------------------------------------
#
# HtmlLinkDoc
@ -119,7 +111,7 @@ class IndividualPage:
self.id_link = idlink
self.list = map
self.private = private
self.alive = person.probably_alive() and restrict
self.alive = person.probably_alive(db) and restrict
self.photos = (photos == 2) or (photos == 1 and not self.alive)
self.usecomments = not uc
self.dir = dir_name
@ -134,6 +126,18 @@ class IndividualPage:
self.doc.set_title(_("Summary of %s") % name)
self.doc.fix_title()
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
def by_date(self,a_id,b_id):
if not (a_id and b_id):
return 0
a = self.db.find_event_from_id(a_id)
b = self.db.find_event_from_id(b_id)
return Date.compare_dates(a.get_date_object(),b.get_date_object())
#--------------------------------------------------------------------
#
#
@ -490,10 +494,13 @@ class IndividualPage:
return
count = 0
event_list = [ self.person.get_birth(), self.person.get_death() ]
event_list = event_list + self.person.get_event_list()
event_list.sort(by_date)
for event in event_list:
event_id_list = [ self.person.get_birth_id(), self.person.get_death_id() ]
event_id_list = event_id_list + self.person.get_event_list()
event_id_list.sort(self.by_date)
for event_id in event_id_list:
if not event_id:
continue
event = self.db.find_event_from_id(event_id)
if event.get_privacy():
continue
name = _(event.get_name())
@ -629,7 +636,9 @@ class IndividualPage:
self.doc.end_row()
if not self.alive:
for event in family.get_event_list():
for event_id in family.get_event_list():
if event_id:
event = self.db.find_event_from_id(event_id)
if event.get_privacy() == 0:
self.write_fam_fact(event)