Removed libaccess, improved birth and death lookup in IndividualPages.

svn: r15032
This commit is contained in:
Rob G. Healey 2010-04-04 23:36:55 +00:00
parent a5079f5031
commit 35874b1145

View File

@ -61,14 +61,14 @@ from collections import defaultdict
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import logging import logging
log = logging.getLogger(".WebPage") log = logging.getLogger(".NarrativeWeb")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# GRAMPS module # GRAMPS module
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gen.ggettext import sgettext as _ from gen.ggettext import sgettext as _
import gen.lib import gen.lib
from gen.lib import UrlType, date, FamilyRelType from gen.lib import UrlType, date, Date, FamilyRelType
import const import const
import Sort import Sort
from gen.plug.menu import PersonOption, NumberOption, StringOption, \ from gen.plug.menu import PersonOption, NumberOption, StringOption, \
@ -98,9 +98,6 @@ from libhtmlbackend import HtmlBackend
from libgedcom import make_gedcom_date from libgedcom import make_gedcom_date
# import library to access SQL database
from libaccess import *
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# constants # constants
@ -1916,15 +1913,9 @@ class IndividualListPage(BasePage):
tcell = Html("td", class_ = "ColumnBirth", inline = True) tcell = Html("td", class_ = "ColumnBirth", inline = True)
trow += tcell trow += tcell
birth_ref = person.get_birth_ref() birth_date = _find_birth_date(db, person)
if birth_ref: if birth_date is not None:
birth = db.get_event_from_handle(birth_ref.ref)
if birth:
birth_date = _dd.display(birth.get_date_object())
if birth.get_type() == gen.lib.EventType.BIRTH:
tcell += birth_date tcell += birth_date
else:
tcell += Html('em', birth_date)
else: else:
tcell += " " tcell += " "
@ -4794,9 +4785,7 @@ class AddressBookListPage(BasePage):
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
# local counters for total line index = 1
index, countadd, countres, counturl, countfb = 0, 0, 0, 0, 0
for (sort_name, person_handle, has_add, has_res, has_url) in has_url_address: for (sort_name, person_handle, has_add, has_res, has_url) in has_url_address:
address = None address = None
@ -4806,24 +4795,19 @@ class AddressBookListPage(BasePage):
# has address but no residence event # has address but no residence event
if has_add and not has_res: if has_add and not has_res:
address = "X" address = "X"
countadd += 1
# has residence, but no addresses # has residence, but no addresses
elif has_res and not has_add: elif has_res and not has_add:
residence = "X" residence = "X"
countres += 1
# has residence and addresses too # has residence and addresses too
elif has_add and has_res: elif has_add and has_res:
address = "X" address = "X"
residence = "X" residence = "X"
countadd += 1
countres += 1
# has Web Links # has Web Links
if has_url: if has_url:
weblinks = "X" weblinks = "X"
counturl += 1
trow = Html("tr") trow = Html("tr")
tbody += trow tbody += trow
@ -4831,7 +4815,7 @@ class AddressBookListPage(BasePage):
trow.extend( trow.extend(
Html("td", data or " ", class_="Column" + colclass, inline = True) Html("td", data or " ", class_="Column" + colclass, inline = True)
for (colclass, data) in [ for (colclass, data) in [
["RowLabel", index + 1], ["RowLabel", index],
["Name", self.addressbook_link(person_handle)], ["Name", self.addressbook_link(person_handle)],
["Address", address], ["Address", address],
["Residence", residence], ["Residence", residence],
@ -4839,16 +4823,6 @@ class AddressBookListPage(BasePage):
) )
index += 1 index += 1
# create totals row for table
trow = Html("tr", class_ = "Totals") + (
Html("td", _("Total"), classs_ = "ColumnRowlabel", inline = True),
Html("td", " ", class_ = "ColumnName", inline = True),
Html("td", countadd, class_ = "ColumnAddress", inline = True),
Html("td", countres, class_ = "ColumnResidence", inline = True),
Html("td", counturl, class_ = "ColumnWebLinks", inline = True)
)
tbody += trow
# Add footer and clearline # Add footer and clearline
footer = self.write_footer() footer = self.write_footer()
body += (fullclear, footer) body += (fullclear, footer)
@ -5068,9 +5042,6 @@ class NavWebReport(Report):
self.progress = ProgressMeter(_("Narrated Web Site Report"), '') self.progress = ProgressMeter(_("Narrated Web Site Report"), '')
# initialize database for use with libaccess library
init(self.database)
# Build the person list # Build the person list
ind_list = self.build_person_list() ind_list = self.build_person_list()
@ -6244,6 +6215,19 @@ def add_birthdate(db, childlist):
# return the list of child handles and their birthdates # return the list of child handles and their birthdates
return sorted_children return sorted_children
def _find_birth_date(db, person):
birth_ref = person.get_birth_ref()
if birth_ref:
birth = db.get_event_from_handle(birth_ref.ref)
return birth.get_date_object()
else:
event_list = person.get_primary_event_ref_list()
for event_ref in event_list:
event = db.get_event_from_handle(event_ref.ref)
if event.get_type().is_birth_fallback():
return event.get_date_object()
return None
def _find_death_date(db, person): def _find_death_date(db, person):
death_ref = person.get_death_ref() death_ref = person.get_death_ref()
if death_ref: if death_ref: