Re-worked IndividualListPage().

svn: r12664
This commit is contained in:
Rob G. Healey 2009-06-13 18:49:18 +00:00
parent 44028cc47c
commit 33ad285de6

View File

@ -1181,198 +1181,187 @@ class IndividualListPage(BasePage):
def __init__(self, report, title, person_handle_list): def __init__(self, report, title, person_handle_list):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
db = report.database
of = self.report.create_file("individuals") of = self.report.create_file("individuals")
IndList, body = self.write_header(_('Individuals')) indlistpage, body = self.write_header(_('Individuals'))
# begin individuals division # begin individuals division
sect_indlist = Html('div', id='Individuals', class_='content') with Html('div', class_='content', id='Individuals') as sect_indlist:
body += sect_indlist
# Individual List description # Individual List description
msg = _("This page contains an index of all the individuals in the " msg = _("This page contains an index of all the individuals in the "
"database, sorted by their last names. Selecting the person’s " "database, sorted by their last names. Selecting the person’s "
"name will take you to that person’s individual page.") "name will take you to that person’s individual page.")
descr = Html('p', msg, id='description') sect_indlist += Html('p', msg, id='description')
sect_indlist += descr
# begin alphabetic navigation # begin alphabetic navigation
alpha_nav = alphabet_navigation(report.database, person_handle_list, _PERSON) alpha_nav = alphabet_navigation(db, person_handle_list, _PERSON)
if alpha_nav is not None: if alpha_nav is not None:
sect_indlist += alpha_nav sect_indlist += alpha_nav
# begin table # begin individuals list table and table head
indlist_table = Html('table', class_='infolist IndividualList') with Html('table', class_='infolist IndividualList') as ind_table:
sect_indlist += ind_table
with Html('thead') as thead:
ind_table += thead
tabhead = []
# table header tabhead.append('Surname')
thead = Html('thead') tabhead.append('Name')
tabrow = Html('tr') column_count = 2
# Table Header -- Surname and Given name columns # birth column
tabcol1 = Html('th', _('Surname'), class_='ColumnSurname', inline=True) if report.options['showbirth']:
tabcol2 = Html('th', _('Name'), class_='ColumnName', inline=True) tabhead.append('Birth')
tabrow += (tabcol1, tabcol2) column_count += 1
column_count = 2
# table header -- show birth column # death column
if report.options['showbirth']: if report.options['showdeath']:
tabcol = Html('th', _('Birth'), class_='ColumnBirth', inline=True) tabhead.append('Death')
tabrow += tabcol column_count += 1
column_count += 1
# table header -- show death column # partmer column
if report.options['showdeath']: if report.options['showpartner']:
tabcol = Html('th', _('Death'), class_='ColumnDeath', inline=True) tabhead.append('Partner')
tabrow += tabcol column_count += 1
column_count += 1
# table header -- show partmer column # parents column
if report.options['showpartner']: if report.options['showparents']:
tabcol = Html('th', _('Partner'), class_='ColumnPartner', inline=True) tabhead.append('Parents')
tabrow += tabcol column_count += 1
column_count += 1 trow = Html('tr')
thead += trow
for column in tabhead:
trow += Html('th', column, class_='Column%s' % column, inline=True)
# table header -- show parents column # begin table body
if report.options['showparents']: with Html('tbody') as tbody:
tabcol = Html('th', _('Parents'), class_='ColumnParents', inline=True) ind_table += tbody
tabrow += tabcol
column_count += 1
thead += tabrow
# begin table body # list of person handles for this report
tbody = Html('tbody') report_handle_list = person_handle_list
person_handle_list = sort_people(db, person_handle_list)
# list of person handles for this report for (surname, handle_list) in person_handle_list:
report_handle_list = person_handle_list first = True
person_handle_list = sort_people(report.database, person_handle_list) if surname:
letter = normalize('NFKC', surname)[0].upper()
for (surname, handle_list) in person_handle_list:
first = True
if surname:
letter = normalize('NFKC', surname)[0].upper()
else:
letter = u' '
# See : http://www.gramps-project.org/bugs/view.php?id=2933
(lang_country, modifier ) = locale.getlocale()
if lang_country == "sv_SE" and ( letter == u'W' or letter == u'V' ):
letter = u'V,W'
for person_handle in handle_list:
person = report.database.get_person_from_handle(person_handle)
# surname column
if first:
tabrow = Html('tr', class_='BeginSurname')
if surname:
tabcol = Html('td', class_='ColumnSurname', inline=True)
hyper = Html('a', surname, name='%s' % letter, tile="Letter %s" % letter,
inline=True)
tabcol += hyper
else:
tabcol = Html('td', ' ', class_='ColumnSurname', inline=True)
else:
tabrow = Html('tr')
tabcol = Html('td', ' ', class_='ColumnSurname', inline=True)
tabrow += tabcol
# firstname column
tabcol = Html('td', class_='ColumnName')
url = self.report.build_url_fname_html(person.handle, 'ppl')
first_suffix = _get_short_name(person.gender, person.primary_name)
hyper = self.person_link(url, first_suffix, person.gramps_id)
tabcol += hyper
tabrow += tabcol
# birth column
if report.options['showbirth']:
tabcol = Html('td', class_='ColumnBirth', inline=True)
birth = ReportUtils.get_birth_or_fallback(report.database, person)
if birth:
if birth.get_type() == EventType.BIRTH:
tabcol += _dd.display(birth.get_date_object())
else: else:
tabcol += Html('em', _dd.display(birth.get_date_object()), inline=True) letter = u' '
else: # See : http://www.gramps-project.org/bugs/view.php?id=2933
tabcol += ' ' (lang_country, modifier ) = locale.getlocale()
tabrow += tabcol if lang_country == "sv_SE" and ( letter == u'W' or letter == u'V' ):
letter = u'V,W'
for person_handle in handle_list:
person = db.get_person_from_handle(person_handle)
# death column # surname column
if report.options['showdeath']: if first:
tabcol = Html('td', class_='ColumnDeath', inline=True) trow = Html('tr', class_='BeginSurname')
death = ReportUtils.get_death_or_fallback(report.database, person) tbody += trow
if death: if surname:
if death.get_type() == EventType.DEATH: tcell = Html('td', class_='ColumnSurname', inline=True)
tabcol += _dd.display(death.get_date_object()) tcell += Html('a', surname, name='%s' % letter,
else: tile="Letter %s" % letter, inline=True)
tabcol += Html('em', _dd.display(death.get_date_object()), inline=True)
else:
tabcol += ' '
tabrow += tabcol
# partner column
if report.options['showpartner']:
tabcol = Html('td', class_='ColumnPartner')
family_list = person.get_family_handle_list()
first_family = True
spouse_name = None
if family_list:
for family_handle in family_list:
family = report.database.get_family_from_handle(family_handle)
partner_handle = ReportUtils.find_spouse(person, family)
if partner_handle:
partner = report.database.get_person_from_handle(partner_handle)
partner_name = self.get_name(partner)
if not first_family:
tabcol += ', '
if partner_handle in report_handle_list:
url = self.report.build_url_fname_html(partner_handle, 'ppl')
hyper = self.person_link(url, partner_name)
tabcol += hyper
else: else:
tabcol += partner_name tcell = Html('td', ' ', class_='ColumnSurname',
first_family = False inline=True)
else: else:
tabcol += ' ' trow = Html('tr')
tabrow += tabcol tbody += trow
tcell = Html('td', ' ', class_='ColumnSurname',
inline=True)
trow += tcell
# parents column # firstname column
if report.options['showparents']: tcell = Html('td', class_='ColumnName')
tabcol = Html('td', class_='ColumnParents') url = self.report.build_url_fname_html(person.handle, 'ppl')
parent_handle_list = person.get_parent_family_handle_list() first_suffix = _get_short_name(person.gender, person.primary_name)
if parent_handle_list: tcell += self.person_link(url, first_suffix, person.gramps_id)
parent_handle = parent_handle_list[0] trow += tcell
family = report.database.get_family_from_handle(parent_handle)
father_name = ''
mother_name = ''
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
father = report.database.get_person_from_handle(father_handle)
mother = report.database.get_person_from_handle(mother_handle)
if father:
father_name = self.get_name(father)
if mother:
mother_name = self.get_name(mother)
if mother and father:
fathercol = Html('span', father_name, class_='father fatherNmother')
mothercol = Html('span', mother_name, class_='mother')
tabcol += (fathercol, mothercol)
elif mother:
mothercol = Html('span', mother_name, class_='mother')
tabcol += mothercol
elif father:
fathercol = Html('span', father_name, class_='father')
tabcol += fathercol
elif not father and not mother:
tabcol = Html('td', class_='ColumnParents', inline=True)
else:
tabcol += ' '
tabrow += tabcol
# finished writing all columns # birth column
tbody += tabrow if report.options['showbirth']:
first = False tcell = Html('td', class_='ColumnBirth', inline=True)
birth = ReportUtils.get_birth_or_fallback(db, person)
if birth:
birth_date = _dd.display(birth.get_date_object())
if birth.get_type() == EventType.BIRTH:
tcell += birth_date
else:
tcell += Html('em', birth_date)
else:
tcell += ' '
trow += tcell
# bring table pieces togther and close table # death column
indlist_table += (thead, tbody) if report.options['showdeath']:
sect_indlist += indlist_table tcell = Html('td', class_='ColumnDeath', inline=True)
death = ReportUtils.get_death_or_fallback(db, person)
if death:
death_date = _dd.display(death.get_date_object())
if death.get_type() == EventType.DEATH:
tcell += death_date
else:
tcell += Html('em', death_date)
else:
tcell += ' '
trow += tcell
# partner column
if report.options['showpartner']:
tcell= Html('td', class_='ColumnPartner')
family_list = person.get_family_handle_list()
first_family = True
if family_list:
for family_handle in family_list:
family = db.get_family_from_handle(family_handle)
partner_handle = ReportUtils.find_spouse(person, family)
if partner_handle:
partner = db.get_person_from_handle(partner_handle)
partner_name = self.get_name(partner)
if not first_family:
tcell += ', '
if partner_handle in report_handle_list:
url = self.report.build_url_fname_html(
partner_handle, 'ppl')
tcell += self.person_link(url, partner_name)
else:
tcell += partner_name
first_family = False
else:
tcell += ' '
trow += tcell
# parents column
if report.options['showparents']:
tcell = Html('td', class_='ColumnParents')
parent_handle_list = person.get_parent_family_handle_list()
if parent_handle_list:
parent_handle = parent_handle_list[0]
family = db.get_family_from_handle(parent_handle)
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
father = db.get_person_from_handle(father_handle)
mother = db.get_person_from_handle(mother_handle)
if father:
father_name = self.get_name(father)
if mother:
mother_name = self.get_name(mother)
if mother and father:
tcell += Html('span', father_name,
class_='father fatherNmother') + (
Html('span', mother_name, class_='mother')
)
elif mother:
tcell += Html('span', mother_name, class_='mother')
elif father:
tcell += Html('span', father_name, class_='father')
else:
tcell += ' '
trow += tcell
# create footer section # create footer section
# create clear line for proper styling # create clear line for proper styling
@ -1381,7 +1370,7 @@ class IndividualListPage(BasePage):
body += (sect_indlist, fullclear, footer) body += (sect_indlist, fullclear, footer)
# send page out for processing # send page out for processing
self.mywriter(IndList, of) self.mywriter(indlistpage, of)
class PlaceListPage(BasePage): class PlaceListPage(BasePage):