* src/ReportUtils.py: use today for age calculation if not

death date exists.
* src/plugins/NavWebPage.py: handle privacy if requested


svn: r4064
This commit is contained in:
Don Allingham 2005-02-20 23:27:55 +00:00
parent f17e644a16
commit f8c349fc78
3 changed files with 304 additions and 291 deletions

View File

@ -1,3 +1,8 @@
2005-02-20 Don Allingham <dallingham@users.sourceforge.net>
* src/ReportUtils.py: use today for age calculation if not
death date exists.
* src/plugins/NavWebPage.py: handle privacy if requested
2005-02-19 Don Allingham <dallingham@users.sourceforge.net> 2005-02-19 Don Allingham <dallingham@users.sourceforge.net>
* src/ChooseParents.py: readonly fixes * src/ChooseParents.py: readonly fixes

View File

@ -27,8 +27,11 @@
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import Date import Date
import DateHandler
import RelLib import RelLib
from NameDisplay import displayer as _nd from NameDisplay import displayer as _nd
import time
from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -168,6 +171,10 @@ def draw_vertical_bar_graph(doc, format, start_x, start_y, height, width, data):
doc.draw_bar(data[index][0],start,bottom-size,start+box_width,bottom) doc.draw_bar(data[index][0],start,bottom-size,start+box_width,bottom)
start += box_width * 1.5 start += box_width * 1.5
_t = time.localtime(time.time())
_TODAY = DateHandler.parser.parse("%04d-%02d-%02d" % (_t[0],_t[1],_t[2]))
def estimate_age(db, person, end_handle=None, start_handle=None): def estimate_age(db, person, end_handle=None, start_handle=None):
""" """
Estimates the age of a person based off the birth and death Estimates the age of a person based off the birth and death
@ -202,11 +209,14 @@ def estimate_age(db, person, end_handle=None, start_handle=None):
dhandle = person.get_death_handle() dhandle = person.get_death_handle()
# if either of the events is not defined, return an error message # if either of the events is not defined, return an error message
if not bhandle or not dhandle: if not bhandle:
return (-1,-1) return (-1,-1)
bdata = db.get_event_from_handle(bhandle).get_date_object() bdata = db.get_event_from_handle(bhandle).get_date_object()
ddata = db.get_event_from_handle(dhandle).get_date_object() if dhandle:
ddata = db.get_event_from_handle(dhandle).get_date_object()
else:
ddata = _TODAY
# if the date is not valid, return an error message # if the date is not valid, return an error message
if not bdata.get_valid() or not ddata.get_valid(): if not bdata.get_valid() or not ddata.get_valid():
@ -263,21 +273,31 @@ def sanitize_person(db,person):
# copy gender # copy gender
new_person.set_gender(person.get_gender()) new_person.set_gender(person.get_gender())
new_person.set_gramps_id(person.get_gramps_id())
new_person.set_handle(person.get_handle())
# copy names if not private # copy names if not private
name = person.get_primary_name()
if name.get_privacy() or person.get_privacy(): if name.get_privacy() or person.get_privacy():
name = RelLib.Name() name = RelLib.Name()
name.set_first_name(_('Private')) name.set_first_name(_('Private'))
name.set_surname(_('Private')) name.set_surname(_('Private'))
else: else:
name = person.get_primary_name()
new_person.set_nick_name(person.get_nick_name()) new_person.set_nick_name(person.get_nick_name())
new_person.set_primary_name(name)
# copy Family reference list
for handle in person.get_family_handle_list():
new_person.add_family_handle(handle)
# copy Family reference list
for item in person.get_parent_family_handle_list():
new_person.add_parent_family_handle(item[0],item[1],item[2])
if person.get_privacy(): if person.get_privacy():
return new_person return new_person
new_person.set_primary_name(name)
for name in person.get_alternate_names(): for name in person.get_alternate_names():
if not name.get_privacy(): if not name.get_privacy():
new_person.add_alternate_name(name) new_person.add_alternate_name(name)
@ -322,10 +342,6 @@ def sanitize_person(db,person):
for obj in person.get_media_list(): for obj in person.get_media_list():
new_person.add_media_reference(RelLib.MediaRef(obj)) new_person.add_media_reference(RelLib.MediaRef(obj))
# copy Family reference list
for handle in person.get_family_handle_list():
new_person.add_family_handle(handle)
# LDS ordinances # LDS ordinances
ordinance = person.get_lds_baptism() ordinance = person.get_lds_baptism()
if ordinance: if ordinance:

View File

@ -131,44 +131,44 @@ class BasePage:
def lnkfmt(self,text): def lnkfmt(self,text):
return text.replace(' ','%20') return text.replace(' ','%20')
def display_footer(self,ofile): def display_footer(self,of):
ofile.write('<br>\n') of.write('<br>\n')
ofile.write('<br>\n') of.write('<br>\n')
ofile.write('<hr>\n') of.write('<hr>\n')
ofile.write('<div class="footer">Generated by ') of.write('<div class="footer">Generated by ')
ofile.write('<a href="http://gramps.sourceforge.net">GRAMPS</a> ') of.write('<a href="http://gramps.sourceforge.net">GRAMPS</a> ')
ofile.write('on 13 December 2004.') of.write('on 13 December 2004.')
ofile.write('</div>\n') of.write('</div>\n')
ofile.write('</body>\n') of.write('</body>\n')
ofile.write('</html>\n') of.write('</html>\n')
def display_header(self,ofile,title,author=""): def display_header(self,of,title,author=""):
ofile.write('<!DOCTYPE HTML PUBLIC ') of.write('<!DOCTYPE HTML PUBLIC ')
ofile.write('"-//W3C//DTD HTML 4.01 Transitional//EN">\n') of.write('"-//W3C//DTD HTML 4.01 Transitional//EN">\n')
ofile.write('<html>\n<head>\n') of.write('<html>\n<head>\n')
ofile.write('<title>%s</title>\n' % self.title_str) of.write('<title>%s</title>\n' % self.title_str)
ofile.write('<meta http-equiv="Content-Type" content="text/html; ') of.write('<meta http-equiv="Content-Type" content="text/html; ')
ofile.write('charset=ISO-8859-1">\n') of.write('charset=ISO-8859-1">\n')
ofile.write('<link href="%s" ' % _NARRATIVE) of.write('<link href="%s" ' % _NARRATIVE)
ofile.write('rel="stylesheet" type="text/css">\n') of.write('rel="stylesheet" type="text/css">\n')
ofile.write('<link href="favicon.png" rel="Shortcut Icon">\n') of.write('<link href="favicon.png" rel="Shortcut Icon">\n')
ofile.write('</head>\n') of.write('</head>\n')
ofile.write('<body>\n') of.write('<body>\n')
ofile.write('<div class="navheader">\n') of.write('<div class="navheader">\n')
ofile.write(' <div class="navbyline">By: %s</div>\n' % author) of.write(' <div class="navbyline">By: %s</div>\n' % author)
ofile.write(' <h1 class="navtitle">%s</h1>\n' % self.title_str) of.write(' <h1 class="navtitle">%s</h1>\n' % self.title_str)
ofile.write(' <hr>\n') of.write(' <hr>\n')
ofile.write(' <div class="nav">\n') of.write(' <div class="nav">\n')
ofile.write(' <a href="index.html">Home</a> &nbsp;\n') of.write(' <a href="index.html">Home</a> &nbsp;\n')
ofile.write(' <a href="introduction.html">Introduction</a> &nbsp;\n') of.write(' <a href="introduction.html">Introduction</a> &nbsp;\n')
ofile.write(' <a href="surnames.html">Surnames</a> &nbsp;\n') of.write(' <a href="surnames.html">Surnames</a> &nbsp;\n')
ofile.write(' <a href="individuals.html">Individuals</a> &nbsp;\n') of.write(' <a href="individuals.html">Individuals</a> &nbsp;\n')
ofile.write(' <a href="sources.html">Sources</a> &nbsp;\n') of.write(' <a href="sources.html">Sources</a> &nbsp;\n')
ofile.write(' <a href="places.html">Places</a> &nbsp;\n') of.write(' <a href="places.html">Places</a> &nbsp;\n')
ofile.write(' <a href="download.html">Download</a> &nbsp;\n') of.write(' <a href="download.html">Download</a> &nbsp;\n')
ofile.write(' <a href="contact.html">Contact</a> &nbsp;\n') of.write(' <a href="contact.html">Contact</a> &nbsp;\n')
ofile.write(' </div>\n') of.write(' </div>\n')
ofile.write(' </div>\n') of.write(' </div>\n')
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -181,18 +181,18 @@ class IndividualListPage(BasePage):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"individuals.html") page_name = os.path.join(html_dir,"individuals.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Individuals'), self.display_header(of,_('Individuals'),
db.get_researcher().get_name()) db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Individuals')) of.write('<h3>%s</h3>\n' % _('Individuals'))
ofile.write('<p>%s</p>\n' % _('Index of individuals, sorted by last name.')) of.write('<p>%s</p>\n' % _('Index of individuals, sorted by last name.'))
ofile.write('<blockquote>\n') of.write('<blockquote>\n')
ofile.write('<table class="infolist" cellspacing="0" ') of.write('<table class="infolist" cellspacing="0" ')
ofile.write('cellpadding="0" border="0">\n') of.write('cellpadding="0" border="0">\n')
ofile.write('<tr><td class="field"><u><b>%s</b></u></td>\n' % _('Surname')) of.write('<tr><td class="field"><u><b>%s</b></u></td>\n' % _('Surname'))
ofile.write('<td class="field"><u><b>%s</b></u></td>\n' % _('Name')) of.write('<td class="field"><u><b>%s</b></u></td>\n' % _('Name'))
ofile.write('</tr>\n') of.write('</tr>\n')
self.sort = Sort.Sort(db) self.sort = Sort.Sort(db)
person_handle_list.sort(self.sort.by_last_name) person_handle_list.sort(self.sort.by_last_name)
@ -202,22 +202,22 @@ class IndividualListPage(BasePage):
person = db.get_person_from_handle(person_handle) person = db.get_person_from_handle(person_handle)
n = person.get_primary_name().get_surname() n = person.get_primary_name().get_surname()
if n != last_surname: if n != last_surname:
ofile.write('<tr><td colspan="2">&nbsp;</td></tr>\n') of.write('<tr><td colspan="2">&nbsp;</td></tr>\n')
ofile.write('<tr><td class="category">') of.write('<tr><td class="category">')
if n != last_surname: if n != last_surname:
ofile.write('<a name="%s">%s</a>' % (self.lnkfmt(n),n)) of.write('<a name="%s">%s</a>' % (self.lnkfmt(n),n))
else: else:
ofile.write('&nbsp') of.write('&nbsp')
ofile.write('</td><td class="data">') of.write('</td><td class="data">')
ofile.write(person.get_primary_name().get_first_name()) of.write(person.get_primary_name().get_first_name())
ofile.write(' <a href="%s.html">' % person.gramps_id) of.write(' <a href="%s.html">' % person.gramps_id)
ofile.write("<sup>[%s]</sup>" % person.gramps_id) of.write("<sup>[%s]</sup>" % person.gramps_id)
ofile.write('</a></td></tr>\n') of.write('</a></td></tr>\n')
last_surname = n last_surname = n
ofile.write('</table>\n</blockquote>\n') of.write('</table>\n</blockquote>\n')
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
return return
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -230,22 +230,22 @@ class PlaceListPage(BasePage):
def __init__(self, db, title, place_handles, html_dir, src_list): def __init__(self, db, title, place_handles, html_dir, src_list):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"places.html") page_name = os.path.join(html_dir,"places.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Places'), self.display_header(of,_('Places'),
db.get_researcher().get_name()) db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Places')) of.write('<h3>%s</h3>\n' % _('Places'))
ofile.write('<p>%s</p>\n' % _('Index of all the places in the ' of.write('<p>%s</p>\n' % _('Index of all the places in the '
'project.')) 'project.'))
ofile.write('<blockquote>\n') of.write('<blockquote>\n')
ofile.write('<table class="infolist" cellspacing="0" ') of.write('<table class="infolist" cellspacing="0" ')
ofile.write('cellpadding="0" border="0">\n') of.write('cellpadding="0" border="0">\n')
ofile.write('<tr><td class="field"><u>') of.write('<tr><td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Letter')) of.write('<b>%s</b></u></td>\n' % _('Letter'))
ofile.write('<td class="field"><u>') of.write('<td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Place')) of.write('<b>%s</b></u></td>\n' % _('Place'))
ofile.write('</tr>\n') of.write('</tr>\n')
self.sort = Sort.Sort(db) self.sort = Sort.Sort(db)
handle_list = list(place_handles) handle_list = list(place_handles)
@ -262,25 +262,25 @@ class PlaceListPage(BasePage):
if n[0] != last_letter: if n[0] != last_letter:
last_letter = n[0] last_letter = n[0]
ofile.write('<tr><td colspan="2">&nbsp;</td></tr>\n') of.write('<tr><td colspan="2">&nbsp;</td></tr>\n')
ofile.write('<tr><td class="category">%s</td>' % last_letter) of.write('<tr><td class="category">%s</td>' % last_letter)
ofile.write('<td class="data">') of.write('<td class="data">')
ofile.write(n) of.write(n)
ofile.write(' <sup><a href="%s.html">' % place.gramps_id) of.write(' <sup><a href="%s.html">' % place.gramps_id)
ofile.write('[%s]' % place.gramps_id) of.write('[%s]' % place.gramps_id)
ofile.write('</a></sup></td></tr>') of.write('</a></sup></td></tr>')
elif n != last_letter: elif n != last_letter:
last_surname = n last_surname = n
ofile.write('<tr><td class="category">&nbsp;</td>') of.write('<tr><td class="category">&nbsp;</td>')
ofile.write('<td class="data">') of.write('<td class="data">')
ofile.write(n) of.write(n)
ofile.write(' <sup><a href="%s">' % place.gramps_id) of.write(' <sup><a href="%s">' % place.gramps_id)
ofile.write('[%s]' % place.gramps_id) of.write('[%s]' % place.gramps_id)
ofile.write('</a></sup></td></tr>') of.write('</a></sup></td></tr>')
ofile.write('</table>\n</blockquote>\n') of.write('</table>\n</blockquote>\n')
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -293,24 +293,24 @@ class SurnameListPage(BasePage):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"surnames.html") page_name = os.path.join(html_dir,"surnames.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Surnames'), self.display_header(of,_('Surnames'),
db.get_researcher().get_name()) db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Surnames')) of.write('<h3>%s</h3>\n' % _('Surnames'))
ofile.write('<p>%s</p>\n' % _('Index of all the surnames in the ' of.write('<p>%s</p>\n' % _('Index of all the surnames in the '
'project. The links lead to a list ' 'project. The links lead to a list '
'of individuals in the database with ' 'of individuals in the database with '
'this same surname.')) 'this same surname.'))
ofile.write('<blockquote>\n') of.write('<blockquote>\n')
ofile.write('<table class="infolist" cellspacing="0" ') of.write('<table class="infolist" cellspacing="0" ')
ofile.write('cellpadding="0" border="0">\n') of.write('cellpadding="0" border="0">\n')
ofile.write('<tr><td class="field"><u>') of.write('<tr><td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Letter')) of.write('<b>%s</b></u></td>\n' % _('Letter'))
ofile.write('<td class="field"><u>') of.write('<td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Surname')) of.write('<b>%s</b></u></td>\n' % _('Surname'))
ofile.write('</tr>\n') of.write('</tr>\n')
self.sort = Sort.Sort(db) self.sort = Sort.Sort(db)
person_handle_list.sort(self.sort.by_last_name) person_handle_list.sort(self.sort.by_last_name)
@ -326,22 +326,22 @@ class SurnameListPage(BasePage):
if n[0] != last_letter: if n[0] != last_letter:
last_letter = n[0] last_letter = n[0]
ofile.write('<tr><td class="category">%s</td>' % last_letter) of.write('<tr><td class="category">%s</td>' % last_letter)
ofile.write('<td class="data">') of.write('<td class="data">')
ofile.write('<a href="individuals.html#%s">' % self.lnkfmt(n)) of.write('<a href="individuals.html#%s">' % self.lnkfmt(n))
ofile.write(n) of.write(n)
ofile.write('</a></td></tr>') of.write('</a></td></tr>')
elif n != last_surname: elif n != last_surname:
last_surname = n last_surname = n
ofile.write('<tr><td class="category">&nbsp;</td>') of.write('<tr><td class="category">&nbsp;</td>')
ofile.write('<td class="data">') of.write('<td class="data">')
ofile.write('<a href="individuals.html#%s">' % self.lnkfmt(n)) of.write('<a href="individuals.html#%s">' % self.lnkfmt(n))
ofile.write(n) of.write(n)
ofile.write('</a></td></tr>') of.write('</a></td></tr>')
ofile.write('</table>\n</blockquote>\n') of.write('</table>\n</blockquote>\n')
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
return return
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -355,14 +355,14 @@ class IntroductionPage(BasePage):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"introduction.html") page_name = os.path.join(html_dir,"introduction.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Introduction'), self.display_header(of,_('Introduction'),
db.get_researcher().get_name()) db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Introduction')) of.write('<h3>%s</h3>\n' % _('Introduction'))
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -375,14 +375,14 @@ class HomePage(BasePage):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"index.html") page_name = os.path.join(html_dir,"index.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Home'), self.display_header(of,_('Home'),
db.get_researcher().get_name()) db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Home')) of.write('<h3>%s</h3>\n' % _('Home'))
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -395,26 +395,26 @@ class SourcesPage(BasePage):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"sources.html") page_name = os.path.join(html_dir,"sources.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Sources'), self.display_header(of,_('Sources'),
db.get_researcher().get_name()) db.get_researcher().get_name())
handle_list = list(handle_set) handle_list = list(handle_set)
ofile.write('<h3>%s</h3>\n<p>' % _('Sources')) of.write('<h3>%s</h3>\n<p>' % _('Sources'))
ofile.write(_('All sources cited in the project.')) of.write(_('All sources cited in the project.'))
ofile.write('</p>\n<blockquote>\n<table class="infolist">\n') of.write('</p>\n<blockquote>\n<table class="infolist">\n')
index = 1 index = 1
for handle in handle_list: for handle in handle_list:
ofile.write('<tr><td class="category">%d.</td>\n' % index) of.write('<tr><td class="category">%d.</td>\n' % index)
ofile.write('<td class="data">') of.write('<td class="data">')
ofile.write('</td></tr>\n') of.write('</td></tr>\n')
ofile.write('</table>\n<blockquote>\n') of.write('</table>\n<blockquote>\n')
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -427,14 +427,14 @@ class DownloadPage(BasePage):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"download.html") page_name = os.path.join(html_dir,"download.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Download'), self.display_header(of,_('Download'),
db.get_researcher().get_name()) db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Download')) of.write('<h3>%s</h3>\n' % _('Download'))
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -447,14 +447,14 @@ class ContactPage(BasePage):
BasePage.__init__(self,title) BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"contact.html") page_name = os.path.join(html_dir,"contact.html")
ofile = open(page_name, "w") of = open(page_name, "w")
self.display_header(ofile,_('Contact'), self.display_header(of,_('Contact'),
db.get_researcher().get_name()) db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Contact')) of.write('<h3>%s</h3>\n' % _('Contact'))
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -481,26 +481,26 @@ class IndividualPage(BasePage):
self.sort_name = _nd.sorted(self.person) self.sort_name = _nd.sorted(self.person)
self.name = _nd.sorted(self.person) self.name = _nd.sorted(self.person)
ofile = open(os.path.join(dirpath,"%s.html" % person.gramps_id), "w") of = open(os.path.join(dirpath,"%s.html" % person.gramps_id), "w")
self.display_header(ofile, title, self.display_header(of, title,
self.db.get_researcher().get_name()) self.db.get_researcher().get_name())
self.display_ind_general(ofile) self.display_ind_general(of)
self.display_ind_events(ofile) self.display_ind_events(of)
self.display_ind_relationships(ofile) self.display_ind_relationships(of)
self.display_ind_narrative(ofile) self.display_ind_narrative(of)
self.display_ind_sources(ofile) self.display_ind_sources(of)
self.display_ind_pedigree(ofile) self.display_ind_pedigree(of)
self.display_footer(ofile) self.display_footer(of)
ofile.close() of.close()
def display_ind_sources(self,ofile): def display_ind_sources(self,of):
sreflist = self.person.get_source_references() sreflist = self.person.get_source_references()
if not sreflist: if not sreflist:
return return
ofile.write('<h4>%s</h4>\n' % _('Sources')) of.write('<h4>%s</h4>\n' % _('Sources'))
ofile.write('<hr>\n') of.write('<hr>\n')
ofile.write('<table class="infolist" cellpadding="0" ') of.write('<table class="infolist" cellpadding="0" ')
ofile.write('cellspacing="0" border="0">\n') of.write('cellspacing="0" border="0">\n')
index = 1 index = 1
for sref in sreflist: for sref in sreflist:
@ -511,7 +511,7 @@ class IndividualPage(BasePage):
title = source.get_title() title = source.get_title()
publisher = source.get_publication_info() publisher = source.get_publication_info()
date = _dd.display(sref.get_date()) date = _dd.display(sref.get_date())
ofile.write('<tr><td class="field">%d. ' % index) of.write('<tr><td class="field">%d. ' % index)
values = [] values = []
if author: if author:
values.append(author) values.append(author)
@ -521,11 +521,11 @@ class IndividualPage(BasePage):
values.append(publisher) values.append(publisher)
if date: if date:
values.append(date) values.append(date)
ofile.write(', '.join(values)) of.write(', '.join(values))
ofile.write('</td></tr>\n') of.write('</td></tr>\n')
ofile.write('</table>\n') of.write('</table>\n')
def display_ind_pedigree(self,ofile): def display_ind_pedigree(self,of):
parent_handle_list = self.person.get_parent_family_handle_list() parent_handle_list = self.person.get_parent_family_handle_list()
if parent_handle_list: if parent_handle_list:
@ -540,36 +540,36 @@ class IndividualPage(BasePage):
father = None father = None
mother = None mother = None
ofile.write('<h4>%s</h4>\n' % _('Pedigree')) of.write('<h4>%s</h4>\n' % _('Pedigree'))
ofile.write('<hr>\n<br>\n') of.write('<hr>\n<br>\n')
ofile.write('<table class="pedigree">\n') of.write('<table class="pedigree">\n')
ofile.write('<tr><td>\n') of.write('<tr><td>\n')
if father or mother: if father or mother:
ofile.write('<blockquote class="pedigreeind">\n') of.write('<blockquote class="pedigreeind">\n')
if father: if father:
self.pedigree_person(ofile,father) self.pedigree_person(of,father)
if mother: if mother:
self.pedigree_person(ofile,mother) self.pedigree_person(of,mother)
ofile.write('<blockquote class="pedigreeind">\n') of.write('<blockquote class="pedigreeind">\n')
if family: if family:
for child_handle in family.get_child_handle_list(): for child_handle in family.get_child_handle_list():
if child_handle == self.person.handle: if child_handle == self.person.handle:
ofile.write('| <strong>%s</strong><br>\n' % self.name) of.write('| <strong>%s</strong><br>\n' % self.name)
self.pedigree_family(ofile) self.pedigree_family(of)
else: else:
child = self.db.get_person_from_handle(child_handle) child = self.db.get_person_from_handle(child_handle)
self.pedigree_person(ofile,child) self.pedigree_person(of,child)
else: else:
ofile.write('| <strong>%s</strong><br>\n' % self.name) of.write('| <strong>%s</strong><br>\n' % self.name)
self.pedigree_family(ofile) self.pedigree_family(of)
ofile.write('</blockquote>\n') of.write('</blockquote>\n')
if father or mother: if father or mother:
ofile.write('</blockquote>\n') of.write('</blockquote>\n')
ofile.write('</td>\n</tr>\n</table>\n') of.write('</td>\n</tr>\n</table>\n')
def display_ind_general(self,ofile): def display_ind_general(self,of):
photolist = self.person.get_media_list() photolist = self.person.get_media_list()
if photolist: if photolist:
photo_handle = photolist[0].get_reference_handle() photo_handle = photolist[0].get_reference_handle()
@ -577,62 +577,62 @@ class IndividualPage(BasePage):
newpath = self.person.gramps_id + os.path.splitext(photo.get_path())[1] newpath = self.person.gramps_id + os.path.splitext(photo.get_path())[1]
shutil.copyfile(photo.get_path(),os.path.join(self.dirpath,newpath)) shutil.copyfile(photo.get_path(),os.path.join(self.dirpath,newpath))
ofile.write('<div class="snapshot">\n') of.write('<div class="snapshot">\n')
ofile.write('<a href="%s">' % newpath) of.write('<a href="%s">' % newpath)
ofile.write('<img class="thumbnail" border="0" src="%s" ' % newpath) of.write('<img class="thumbnail" border="0" src="%s" ' % newpath)
ofile.write('height="100"></a>') of.write('height="100"></a>')
ofile.write('</div>\n') of.write('</div>\n')
ofile.write('<div class="summaryarea">\n') of.write('<div class="summaryarea">\n')
ofile.write('<h3>%s</h3>\n' % self.sort_name) of.write('<h3>%s</h3>\n' % self.sort_name)
ofile.write('<table class="infolist" cellpadding="0" cellspacing="0" ') of.write('<table class="infolist" cellpadding="0" cellspacing="0" ')
ofile.write('border="0">\n') of.write('border="0">\n')
# Gender # Gender
ofile.write('<tr><td class="field">%s</td>\n' % _('Gender')) of.write('<tr><td class="field">%s</td>\n' % _('Gender'))
gender = self.gender_map[self.person.gender] gender = self.gender_map[self.person.gender]
ofile.write('<td class="data">%s</td>\n' % gender) of.write('<td class="data">%s</td>\n' % gender)
ofile.write('</tr>\n') of.write('</tr>\n')
# Birth # Birth
handle = self.person.get_birth_handle() handle = self.person.get_birth_handle()
if handle: if handle:
event = self.db.get_event_from_handle(handle) event = self.db.get_event_from_handle(handle)
ofile.write('<tr><td class="field">%s</td>\n' % _('Birth')) of.write('<tr><td class="field">%s</td>\n' % _('Birth'))
ofile.write('<td class="data">%s</td>\n' % self.format_event(event)) of.write('<td class="data">%s</td>\n' % self.format_event(event))
ofile.write('</tr>\n') of.write('</tr>\n')
# Death # Death
handle = self.person.get_death_handle() handle = self.person.get_death_handle()
if handle: if handle:
event = self.db.get_event_from_handle(handle) event = self.db.get_event_from_handle(handle)
ofile.write('<tr><td class="field">%s</td>\n' % _('Death')) of.write('<tr><td class="field">%s</td>\n' % _('Death'))
ofile.write('<td class="data">%s</td>\n' % self.format_event(event)) of.write('<td class="data">%s</td>\n' % self.format_event(event))
ofile.write('</tr>\n') of.write('</tr>\n')
ofile.write('</table>\n') of.write('</table>\n')
ofile.write('</div>\n') of.write('</div>\n')
def display_ind_events(self,ofile): def display_ind_events(self,of):
ofile.write('<h4>%s</h4>\n' % _('Events')) of.write('<h4>%s</h4>\n' % _('Events'))
ofile.write('<hr>\n') of.write('<hr>\n')
ofile.write('<table class="infolist" cellpadding="0" cellspacing="0" ') of.write('<table class="infolist" cellpadding="0" cellspacing="0" ')
ofile.write('border="0">\n') of.write('border="0">\n')
for event_id in self.person.get_event_list(): for event_id in self.person.get_event_list():
event = self.db.get_event_from_handle(event_id) event = self.db.get_event_from_handle(event_id)
ofile.write('<tr><td class="field">%s</td>\n' % event.get_name()) of.write('<tr><td class="field">%s</td>\n' % event.get_name())
ofile.write('<td class="data">\n') of.write('<td class="data">\n')
ofile.write(self.format_event(event)) of.write(self.format_event(event))
ofile.write('</td>\n') of.write('</td>\n')
ofile.write('</tr>\n') of.write('</tr>\n')
ofile.write('</table>\n') of.write('</table>\n')
def display_ind_narrative(self,ofile): def display_ind_narrative(self,of):
ofile.write('<h4>%s</h4>\n' % _('Narrative')) of.write('<h4>%s</h4>\n' % _('Narrative'))
ofile.write('<hr>\n') of.write('<hr>\n')
noteobj = self.person.get_note_object() noteobj = self.person.get_note_object()
if noteobj: if noteobj:
@ -643,73 +643,73 @@ class IndividualPage(BasePage):
text = "<pre>" + "<br>".join(text.split("\n")) text = "<pre>" + "<br>".join(text.split("\n"))
else: else:
text = "</p><p>".join(text.split("\n")) text = "</p><p>".join(text.split("\n"))
ofile.write('<p>%s</p>\n' % text) of.write('<p>%s</p>\n' % text)
def display_parent(self,ofile,handle,title): def display_parent(self,of,handle,title):
use_link = handle in self.ind_list use_link = handle in self.ind_list
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
ofile.write('<td class="field">%s</td>\n' % title) of.write('<td class="field">%s</td>\n' % title)
ofile.write('<td class="data">') of.write('<td class="data">')
ofile.write(_nd.display(person)) of.write(_nd.display(person))
if use_link: if use_link:
val = person.gramps_id val = person.gramps_id
ofile.write('&nbsp;<sup><a href="%s.html">[%s]</a></sup>' % (val,val)) of.write('&nbsp;<sup><a href="%s.html">[%s]</a></sup>' % (val,val))
ofile.write('</td>\n') of.write('</td>\n')
def display_ind_relationships(self,ofile): def display_ind_relationships(self,of):
parent_list = self.person.get_parent_family_handle_list() parent_list = self.person.get_parent_family_handle_list()
family_list = self.person.get_family_handle_list() family_list = self.person.get_family_handle_list()
if not parent_list and not family_list: if not parent_list and not family_list:
return return
ofile.write('<h4>%s</h4>\n' % _("Relationships")) of.write('<h4>%s</h4>\n' % _("Relationships"))
ofile.write('<hr>\n') of.write('<hr>\n')
ofile.write('<table class="infolist" cellpadding="0" cellspacing="0" border="0">\n') of.write('<table class="infolist" cellpadding="0" cellspacing="0" border="0">\n')
if parent_list: if parent_list:
for (family_handle,mrel,frel) in parent_list: for (family_handle,mrel,frel) in parent_list:
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
ofile.write('<tr><td colspan="3">&nbsp;</td></tr>\n') of.write('<tr><td colspan="3">&nbsp;</td></tr>\n')
ofile.write('<tr><td class="category">%s</td>\n' % _("Parents")) of.write('<tr><td class="category">%s</td>\n' % _("Parents"))
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if father_handle: if father_handle:
self.display_parent(ofile,father_handle,_('Father')) self.display_parent(of,father_handle,_('Father'))
ofile.write('</tr><tr><td>&nbsp;</td>\n') of.write('</tr><tr><td>&nbsp;</td>\n')
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if mother_handle: if mother_handle:
self.display_parent(ofile,mother_handle,_('Mother')) self.display_parent(of,mother_handle,_('Mother'))
ofile.write('</tr>\n') of.write('</tr>\n')
ofile.write('<tr><td colspan="3">&nbsp;</td></tr>\n') of.write('<tr><td colspan="3">&nbsp;</td></tr>\n')
if family_list: if family_list:
ofile.write('<tr><td class="category">%s</td>\n' % _("Spouses")) of.write('<tr><td class="category">%s</td>\n' % _("Spouses"))
first = True first = True
for family_handle in family_list: for family_handle in family_list:
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
self.display_spouse(ofile,family,first) self.display_spouse(of,family,first)
first = False first = False
childlist = family.get_child_handle_list() childlist = family.get_child_handle_list()
if childlist: if childlist:
ofile.write('<tr><td>&nbsp;</td>\n') of.write('<tr><td>&nbsp;</td>\n')
ofile.write('<td class="field">%s</td>\n' % _("Children")) of.write('<td class="field">%s</td>\n' % _("Children"))
ofile.write('<td class="data">\n') of.write('<td class="data">\n')
for child_handle in childlist: for child_handle in childlist:
use_link = child_handle in self.ind_list use_link = child_handle in self.ind_list
child = self.db.get_person_from_handle(child_handle) child = self.db.get_person_from_handle(child_handle)
if use_link: if use_link:
ofile.write('<a href="%s.html">' % child.get_gramps_id()) of.write('<a href="%s.html">' % child.get_gramps_id())
ofile.write(_nd.display(child)) of.write(_nd.display(child))
if use_link: if use_link:
ofile.write('</a>\n') of.write('</a>\n')
ofile.write("<br>\n") of.write("<br>\n")
ofile.write('</td>\n</tr>\n') of.write('</td>\n</tr>\n')
ofile.write('</table>\n') of.write('</table>\n')
def display_spouse(self,ofile,family,first=True): def display_spouse(self,of,family,first=True):
gender = self.person.get_gender() gender = self.person.get_gender()
reltype = family.get_relationship() reltype = family.get_relationship()
@ -730,52 +730,52 @@ class IndividualPage(BasePage):
else: else:
name = _("unknown") name = _("unknown")
if not first: if not first:
ofile.write('<tr><td>&nbsp;</td></tr>\n') of.write('<tr><td>&nbsp;</td></tr>\n')
ofile.write('<td>&nbsp;</td>') of.write('<td>&nbsp;</td>')
ofile.write('<td class="field">%s</td>\n' % relstr) of.write('<td class="field">%s</td>\n' % relstr)
ofile.write('<td class="data">') of.write('<td class="data">')
use_link = spouse_id in self.ind_list use_link = spouse_id in self.ind_list
if use_link: if use_link:
ofile.write('<a href="%s.html">' % spouse.get_gramps_id()) of.write('<a href="%s.html">' % spouse.get_gramps_id())
ofile.write(name) of.write(name)
if use_link: if use_link:
ofile.write('</a>') of.write('</a>')
ofile.write('</td>\n</tr>\n') of.write('</td>\n</tr>\n')
for event_id in family.get_event_list(): for event_id in family.get_event_list():
event = self.db.get_event_from_handle(event_id) event = self.db.get_event_from_handle(event_id)
ofile.write('<tr><td>&nbsp;</td>\n') of.write('<tr><td>&nbsp;</td>\n')
ofile.write('<td class="field">%s</td>\n' % event.get_name()) of.write('<td class="field">%s</td>\n' % event.get_name())
ofile.write('<td class="data">\n') of.write('<td class="data">\n')
ofile.write(self.format_event(event)) of.write(self.format_event(event))
ofile.write('</td>\n</tr>\n') of.write('</td>\n</tr>\n')
def pedigree_person(self,ofile,person,bullet='|'): def pedigree_person(self,of,person,bullet='|'):
person_link = person.handle in self.ind_list person_link = person.handle in self.ind_list
ofile.write('%s ' % bullet) of.write('%s ' % bullet)
if person_link: if person_link:
ofile.write('<a href="%s.html">' % person.gramps_id) of.write('<a href="%s.html">' % person.gramps_id)
ofile.write(_nd.display(person)) of.write(_nd.display(person))
if person_link: if person_link:
ofile.write('</a>') of.write('</a>')
ofile.write('<br>\n') of.write('<br>\n')
def pedigree_family(self,ofile): def pedigree_family(self,of):
for family_handle in self.person.get_family_handle_list(): for family_handle in self.person.get_family_handle_list():
rel_family = self.db.get_family_from_handle(family_handle) rel_family = self.db.get_family_from_handle(family_handle)
spouse_handle = ReportUtils.find_spouse(self.person,rel_family) spouse_handle = ReportUtils.find_spouse(self.person,rel_family)
if spouse_handle: if spouse_handle:
spouse = self.db.get_person_from_handle(spouse_handle) spouse = self.db.get_person_from_handle(spouse_handle)
self.pedigree_person(ofile,spouse,'&bull;') self.pedigree_person(of,spouse,'&bull;')
childlist = rel_family.get_child_handle_list() childlist = rel_family.get_child_handle_list()
if childlist: if childlist:
ofile.write('<blockquote class="pedigreeind">\n') of.write('<blockquote class="pedigreeind">\n')
for child_handle in childlist: for child_handle in childlist:
child = self.db.get_person_from_handle(child_handle) child = self.db.get_person_from_handle(child_handle)
self.pedigree_person(ofile,child) self.pedigree_person(of,child)
ofile.write('</blockquote>\n') of.write('</blockquote>\n')
def format_event(self,event): def format_event(self,event):
descr = event.get_description() descr = event.get_description()
@ -929,6 +929,9 @@ class WebReport(Report.Report):
for person_handle in ind_list: for person_handle in ind_list:
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
if not self.private:
person = ReportUtils.sanitize_person(self.database,person)
idoc = IndividualPage(self.database, person, self.title, idoc = IndividualPage(self.database, person, self.title,
dir_name, ind_list, place_list, source_list) dir_name, ind_list, place_list, source_list)
self.progress_bar_step() self.progress_bar_step()
@ -1218,19 +1221,8 @@ class WebReportDialog(Report.ReportDialog):
"""Create the object that will produce the web pages.""" """Create the object that will produce the web pages."""
try: try:
MyReport = WebReport(self.database,self.person,self.options_class) MyReport = WebReport(self.database,self.person,
""" self.options_class)
self.target_path,
self.max_gen, self.photos, self.filter,
self.restrict, self.private, self.srccomments,
self.include_link, self.include_mini_tree,
self.selected_style,
self.img_dir_text,self.template_name,
self.use_id,self.id_link,self.use_gendex,self.use_places,
self.html_ext,self.include_alpha_links,
self.separate_alpha,self.n_cols,
self.birth_dates,self.year_only)
"""
MyReport.write_report() MyReport.write_report()
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1,m2) = msg.messages() (m1,m2) = msg.messages()