3131: sibling quickview doesn't reflect person view

svn: r15033
This commit is contained in:
Doug Blank 2010-04-05 02:53:32 +00:00
parent 35874b1145
commit 2842f8e8a5
8 changed files with 54 additions and 15 deletions

View File

@ -27,6 +27,7 @@ from types import NoneType
import gen.lib
import DateHandler
import Utils
import gen.utils
from gen.display.name import displayer as name_displayer
from gen.lib import EventType
@ -515,6 +516,21 @@ class SimpleAccess(object):
person = self.dbase.get_person_from_handle(person)
return self.__event_date_obj(person, gen.lib.Person.get_birth_ref)
def birth_or_fallback(self, person):
"""
Return the date of the person's birth or fallback event.
@param person: Person object
@type person: L{gen.lib.Person}
@return: Returns the date when the person's birth or fallback.
@rtype: L{gen.lib.Date}
"""
if type(person) in [str, unicode]:
person = self.dbase.get_person_from_handle(person)
return gen.utils.get_birth_or_fallback(self.dbase,
person, "<i>%s</i>").date
def birth_place(self, person):
"""
Return a string indicating the place of the person's birth.
@ -554,6 +570,20 @@ class SimpleAccess(object):
person = self.dbase.get_person_from_handle(person)
return self.__event_date_obj(person, gen.lib.Person.get_death_ref)
def death_or_fallback(self, person):
"""
Return the date of the person's death or fallback event.
@param person: Person object
@type person: L{gen.lib.Person}
@return: Returns the date of the person's death or fallback.
@rtype: L{gen.lib.Date}
"""
if type(person) in [str, unicode]:
person = self.dbase.get_person_from_handle(person)
return gen.utils.get_death_or_fallback(self.dbase,
person, "<i>%s</i>").date
def death_place(self, person):
"""
Return a string indicating the place of the person's death.

View File

@ -285,6 +285,9 @@ class SimpleTable(object):
text = DateHandler.displayer.display(item)
retval.append(text)
if item.get_valid():
if item.format:
self.set_cell_markup(col, row,
item.format % cgi.escape(text))
self.row_sort_val(col, item.sortval)
else:
# sort before others:
@ -292,7 +295,7 @@ class SimpleTable(object):
# give formatted version:
invalid_date_format = config.get('preferences.invalid-date-format')
self.set_cell_markup(col, row,
invalid_date_format % text)
invalid_date_format % cgi.escape(text))
if (self.__link_col == col or link is None):
link = ('Date', item)
elif isinstance(item, gen.lib.Span):

View File

@ -683,6 +683,7 @@ class Date(object):
pass # source is ok
else:
raise AttributeError, "invalid args to Date: %s" % source
self.format = None
#### ok, process either date or tuple
if isinstance(source, tuple):
self.calendar = Date.CAL_GREGORIAN

View File

@ -24,7 +24,7 @@
Functional database interface for getting events, or fallback events.
"""
def get_birth_or_fallback(db, person):
def get_birth_or_fallback(db, person, format=None):
"""
Get BIRTH event from a person, or fallback to an event around
the time of birth.
@ -41,10 +41,12 @@ def get_birth_or_fallback(db, person):
if (event
and event.type.is_birth_fallback()
and event_ref.role.is_primary()):
if format:
event.date.format = format
return event
return None
def get_death_or_fallback(db, person):
def get_death_or_fallback(db, person, format=None):
"""
Get a DEATH event from a person, or fallback to an
event around the time of death.
@ -61,5 +63,8 @@ def get_death_or_fallback(db, person):
if (event
and event.type.is_death_fallback()
and event_ref.role.is_primary()):
if format:
event.date.format = format
return event
return None

View File

@ -76,28 +76,28 @@ def run(database, document, filter_name, *args, **kwargs):
if (filter_name == 'all people'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'males'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
if person.gender == Person.MALE:
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'females'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
if person.gender == Person.FEMALE:
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'people with unknown gender'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
if person.gender not in [Person.FEMALE, Person.MALE]:
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'people with incomplete names'):
@ -105,7 +105,7 @@ def run(database, document, filter_name, *args, **kwargs):
for person in database.iter_people():
for name in [person.get_primary_name()] + person.get_alternate_names():
if name.get_group_name() == "" or name.get_first_name() == "":
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'people with missing birth dates'):
@ -125,7 +125,7 @@ def run(database, document, filter_name, *args, **kwargs):
for person in database.iter_people():
if ((not person.get_main_parents_family_handle()) and
(not len(person.get_family_handle_list()))):
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'all families'):
@ -193,7 +193,7 @@ def run(database, document, filter_name, *args, **kwargs):
handles = kwargs["handles"]
for person_handle in handles:
person = database.get_person_from_handle(person_handle)
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
else:

View File

@ -118,7 +118,7 @@ def run(database, document, person):
matches = 0
for person_handle in people:
person = database.get_person_from_handle(person_handle)
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
@ -159,7 +159,7 @@ def run_given(database, document, person):
matches = 0
for person_handle in people:
person = database.get_person_from_handle(person_handle)
stab.row(person, sdb.birth_date_obj(person),
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1

View File

@ -112,8 +112,8 @@ def make_details(gender, person, sa, sd, database, stab) :
rem_str = ""
while person:
person_handle = person.handle
stab.row(person, sa.birth_date_obj(person),
sa.death_date_obj(person), rem_str)
stab.row(person, sa.birth_or_fallback(person),
sa.death_or_fallback(person), rem_str)
#if rem_str:
# sd.paragraph(__FMT_REM % (_("Remark"), rem_str))

View File

@ -61,6 +61,6 @@ def run(database, document, person):
# pass row the child object to make link:
stab.row(child,
sdb.gender(child),
sdb.birth_date_obj(child),
sdb.birth_or_fallback(child),
rel_str)
stab.write(sdoc)