diff --git a/gramps/plugins/webreport/webcal.py b/gramps/plugins/webreport/webcal.py
index 564884ddd..7b5a703dc 100644
--- a/gramps/plugins/webreport/webcal.py
+++ b/gramps/plugins/webreport/webcal.py
@@ -32,7 +32,8 @@ Web Calendar generator.
#------------------------------------------------------------------------
# python modules
#------------------------------------------------------------------------
-import os, shutil
+import os
+import shutil
import datetime
import time
import calendar # Python module
@@ -41,15 +42,14 @@ import calendar # Python module
# Set up logging
#------------------------------------------------------------------------
import logging
-_LOG = logging.getLogger(".WebPage")
#------------------------------------------------------------------------
# Gramps module
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
-_ = glocale.translation.sgettext
from gramps.gen.lib import Date, Name, NameType, Person
from gramps.gen.lib.date import Today
+from gramps.plugins.webreport.common import html_escape
from gramps.gen.const import PROGRAM_NAME, URL_HOMEPAGE
from gramps.version import VERSION
from gramps.gen.constfunc import win
@@ -63,6 +63,7 @@ from gramps.gen.plug.menu import (BooleanOption, NumberOption, StringOption,
PersonOption, DestinationOption, NoteOption)
from gramps.gen.utils.config import get_researcher
from gramps.gen.utils.alive import probably_alive
+from gramps.gen.utils.db import get_death_or_fallback
from gramps.gen.datehandler import displayer as _dd
from gramps.gen.display.name import displayer as _nd
@@ -80,7 +81,11 @@ from gramps.plugins.lib.libhtmlbackend import HtmlBackend
#------------------------------------------------------------------------
# constants
#------------------------------------------------------------------------
+_ = glocale.translation.sgettext
+_LOG = logging.getLogger(".WebPage")
+
# full clear line for proper styling
+
FULLCLEAR = Html("div", class_="fullclear", inline=True)
# Web page filename extensions
@@ -93,18 +98,6 @@ _CALENDARPRINT = 'calendar-print.css'
PLUGMAN = GuiPluginManager.get_instance()
CSS = PLUGMAN.process_plugin_data('WEBSTUFF')
-def _escape(string):
- """ replace character in text that html shows correctly
- special characters: & < and >
- """
- string = string.replace('&', '&') # must be the first
- string = string.replace('<', '<')
- string = string.replace('>', '>')
- return string
-
-# pylint: disable=unused-variable
-# pylint: disable=unused-argument
-
#------------------------------------------------------------------------
#
# WebCalReport
@@ -147,6 +140,7 @@ class WebCalReport(Report):
self.multiyear = mgobn('multiyear')
self.start_year = mgobn('start_year')
self.end_year = mgobn('end_year')
+ self.after_year = mgobn('after_year')
if not self.multiyear:
self.end_year = self.start_year
if self.end_year < self.start_year:
@@ -157,12 +151,14 @@ class WebCalReport(Report):
self.alive = mgobn('alive')
self.birthday = mgobn('birthdays')
self.anniv = mgobn('anniversaries')
+ self.death_anniv = mgobn('death_anniv')
self.home_link = mgobn('home_link')
self.event_list = []
self.month_notes = [mgobn('note_' + month)
- for month in ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul',
- 'aug', 'sep', 'oct', 'nov', 'dec']]
+ for month in ['jan', 'feb', 'mar', 'apr', 'may',
+ 'jun', 'jul', 'aug', 'sep', 'oct',
+ 'nov', 'dec']]
self.encoding = mgobn('encoding')
self.fullyear = True
@@ -228,7 +224,7 @@ class WebCalReport(Report):
s_tags = styledtext.get_tags()
#FIXME: following split should be regex to match \n\s*\n instead?
markuptext = self._backend.add_markup_from_styled(text, s_tags,
- split='\n\n')
+ split='\n\n')
htmllist = Html("div", id="grampsstylednote")
if format_type == 1:
#preformatted, retain whitespace.
@@ -290,19 +286,22 @@ class WebCalReport(Report):
text -- line to be added
year, month, day -- date to add the text to
- event -- one of 'BirthDay', 'Anniversary', or 'Holiday'
+ event -- one of 'BirthDay', 'Anniversary', 'Death' or 'Holiday'
age_at_death -- The age in text. ie : 68 years, 6 months
dead_event_date -- The date of the event used to calculate
the age_at_death
"""
+ if year <= self.after_year:
+ return
+
# This may happen for certain "about" dates.
# Use first day of the month
if day == 0:
day = 1
# determine which dictionary to use???
- if event in ['Birthday', 'Anniversary']:
+ if event in ['Birthday', 'Anniversary', 'Death']:
month_dict = self.calendar.get(month, {})
else:
month_dict = self.holidays.get(month, {})
@@ -321,7 +320,7 @@ class WebCalReport(Report):
month_dict[day] = day_list
# determine which dictionary to add it to???
- if event in ['Birthday', 'Anniversary']:
+ if event in ['Birthday', 'Anniversary', 'Death']:
self.calendar[month] = month_dict
else:
self.holidays[month] = month_dict
@@ -380,7 +379,7 @@ class WebCalReport(Report):
imgs += [CSS["favicon2"]["filename"]]
for from_path in imgs:
- fdir, fname = os.path.split(from_path)
+ dummy_fdir, fname = os.path.split(from_path)
self.copy_file(from_path, fname, "images")
def create_file(self, fname, subdir):
@@ -429,14 +428,14 @@ class WebCalReport(Report):
'initial-scale=1.0, maximum-scale=1.0, user-scalable=1"'
_meta2 = 'name ="apple-mobile-web-app-capable" content="yes"'
_meta3 = 'name="generator" content="%s %s %s"' % (
- PROGRAM_NAME, VERSION, URL_HOMEPAGE)
+ PROGRAM_NAME, VERSION, URL_HOMEPAGE)
_meta4 = 'name="author" content="%s"' % self.author
# create additional meta tags
meta = Html("meta", attr=_meta1) + (
- Html("meta", attr=_meta2, indent=False),
- Html("meta", attr=_meta3, indent=False),
- Html("meta", attr=_meta4, indent=False)
+ Html("meta", attr=_meta2, indent=False),
+ Html("meta", attr=_meta3, indent=False),
+ Html("meta", attr=_meta4, indent=False)
)
# begin each html page...
@@ -457,9 +456,8 @@ class WebCalReport(Report):
# links for Gramps favicon and stylesheets
links = Html("link", rel='shortcut icon',
href=fname1, type="image/x-icon") + (
- Html("link", href=fname2, type="text/css",
- media="screen", rel="stylesheet", indent=False)
- )
+ Html("link", href=fname2, type="text/css",
+ media="screen", rel="stylesheet", indent=False))
# add horizontal menu if css == Blue or Visually because
# there is no menus?
@@ -488,16 +486,16 @@ class WebCalReport(Report):
# Created for ?
msg = None
if self.author and self.email:
+ bemail = '' + self.author + ''
msg = self._('the "WebCal" will be the potential-email Subject|'
- 'Created for %(html_email_author_start)s'
- 'WebCal%(html_email_author_end)s') % {
- 'html_email_author_start' :
- '' + self.author + ''}
+ 'Created for %(html_email_author_start)s'
+ 'WebCal%(html_email_author_end)s') % {
+ 'html_email_author_start' : bemail,
+ 'html_email_author_end' : eemail}
elif self.author:
msg = self._('Created for %(author)s') % {
- 'author' : self.author}
+ 'author' : self.author}
if msg:
header += Html("p", msg, id="CreatorInfo")
@@ -546,8 +544,10 @@ class WebCalReport(Report):
# Figure out if we need
# or just plain
- check_cs = str(cal_year) == currentsection and\
- 'class = "CurrentSection"' or False
+ if str(cal_year) == currentsection:
+ check_cs = 'class = "CurrentSection"'
+ else:
+ check_cs = False
if check_cs:
unordered.extend(
Html("li", hyper, attr=check_cs, inline=True)
@@ -576,7 +576,7 @@ class WebCalReport(Report):
navs.append((self.home_link, self._('Home'), add_home))
navs.extend((self.rlocale.date_displayer.long_months[int(month)],
self.rlocale.date_displayer.short_months[int(month)], True)
- for month in range(1, 13))
+ for month in range(1, 13))
# Add a link for year_glance() if requested
navs.append(('fullyearlinked', self._('Year Glance'), self.fullyear))
@@ -601,7 +601,7 @@ class WebCalReport(Report):
add_subdirs = False
if not (url.startswith('http:') or url.startswith('/')):
add_subdirs = not any(url.endswith(ext)
- for ext in _WEB_EXT)
+ for ext in _WEB_EXT)
# whether to add subdirs or not???
if add_subdirs:
@@ -614,8 +614,10 @@ class WebCalReport(Report):
# Figure out if we need or
# just plain
- check_cs = url_fname == currentsection and \
- 'class = "CurrentSection"' or False
+ if url_fname == currentsection:
+ check_cs = 'class = "CurrentSection"'
+ else:
+ check_cs = False
if url == self.home_link:
mytitle = self._("NarrativeWeb Home")
@@ -729,42 +731,42 @@ class WebCalReport(Report):
full_month_name = date_displayer.long_months[month-1]
url = full_month_name.lower() + self.ext
prevm = Date(int(year), int(month-1), 0)
- my_title = Html("a", _escape("<"), href=url,
+ my_title = Html("a", html_escape("<"), href=url,
title=date_displayer.display(prevm))
elif self.multiyear and year > self.start_year:
full_month_name = date_displayer.long_months[12]
url = full_month_name.lower() + self.ext
dest = os.path.join("../", str(year-1), url)
prevm = Date(int(year-1), 12, 0)
- my_title = Html("a", _escape("<"), href=dest,
+ my_title = Html("a", html_escape("<"), href=dest,
title=date_displayer.display(prevm))
else:
full_month_name = date_displayer.long_months[12]
url = full_month_name.lower() + self.ext
dest = os.path.join("../", str(self.end_year), url)
prevy = Date(self.end_year, 12, 0)
- my_title = Html("a", _escape("<"), href=dest,
+ my_title = Html("a", html_escape("<"), href=dest,
title=date_displayer.display(prevy))
my_title += Html(" ")
if month < 12:
full_month_name = date_displayer.long_months[month+1]
url = full_month_name.lower() + self.ext
nextd = Date(int(year), int(month+1), 0)
- my_title += Html("a", _escape(">"), href=url,
+ my_title += Html("a", html_escape(">"), href=url,
title=date_displayer.display(nextd))
elif self.multiyear and year < self.end_year:
full_month_name = date_displayer.long_months[1]
url = full_month_name.lower() + self.ext
dest = os.path.join("../", str(year+1), url)
nextd = Date(int(year+1), 1, 0)
- my_title += Html("a", _escape(">"), href=dest,
+ my_title += Html("a", html_escape(">"), href=dest,
title=date_displayer.display(nextd))
else:
full_month_name = date_displayer.long_months[1]
url = full_month_name.lower() + self.ext
dest = os.path.join("../", str(self.start_year), url)
nexty = Date(self.start_year, 1, 0)
- my_title += Html("a", _escape(">"), href=dest,
+ my_title += Html("a", html_escape(">"), href=dest,
title=date_displayer.display(nexty))
my_title += Html("")
trow = Html("tr") + (
@@ -792,8 +794,8 @@ class WebCalReport(Report):
table += tbody
# get first of the month and month information
- current_date, current_ord, monthinfo = get_first_day_of_month(year,
- month)
+ (dummy_current_date,
+ current_ord, monthinfo) = get_first_day_of_month(year, month)
# begin calendar table rows, starting week0
nweeks = len(monthinfo)
@@ -841,9 +843,13 @@ class WebCalReport(Report):
# Something this month
if thisday.month == month:
holiday_list = self.holidays.get(month,
- {}).get(thisday.day, [])
+ {}).get(
+ thisday.day,
+ [])
bday_anniv_list = self.calendar.get(month,
- {}).get(thisday.day, [])
+ {}).get(
+ thisday.day,
+ [])
# date is an instance because of subtracting
# abilities in date.py
@@ -892,15 +898,13 @@ class WebCalReport(Report):
# without id tag
tcell = Html("td", class_=hilightday,
inline=True) + (
-
- # adds date division
- Html("div", day, class_="date",
- inline=True)
- )
+ # adds date division
+ Html("div", day,
+ class_="date",
+ inline=True))
# WebCal
else:
-
# add date to table cell
tcell += datediv
@@ -908,30 +912,27 @@ class WebCalReport(Report):
unordered = Html("ul")
tcell += unordered
- for (nyears, date, text,
- event, notused, notused) in day_list:
+ for (dummy_nyears, dummy_date, text,
+ event, dummy_notused,
+ dummy_notused) in day_list:
unordered += Html("li", text,
inline=False
- if event == 'Anniversary' else True)
-
+ if (event ==
+ 'Anniversary')
+ else True)
# no events for this day
else:
-
# create empty day with date
tcell = Html("td", class_=dayclass,
inline=True) + (
-
- # adds date division
- Html("div", day, class_="date", inline=True)
- )
-
+ # adds date division
+ Html("div", day, class_="date",
+ inline=True))
# nothing for this month
else:
tcell = Html("td", class_=dayclass) + (
-
# adds date division
- Html("div", day, class_="date", inline=True)
- )
+ Html("div", day, class_="date", inline=True))
# attach table cell to table row
# close the day column
@@ -949,7 +950,7 @@ class WebCalReport(Report):
class_="week%02d" % (weeks + 1)) as six_weeks:
tbody += six_weeks
- for emptydays in range(7):
+ for dummy_emptydays in range(7):
six_weeks += Html("td", class_="emptyDays",
inline=True)
@@ -972,7 +973,7 @@ class WebCalReport(Report):
nr_up = 1 # Number of directory levels up to get to self.html_dir / root
with self._user.progress(_("Web Calendar Report"),
- _('Formatting months ...'), 12) as step:
+ _('Formatting months ...'), 12) as step:
for month in range(1, 13):
cal_fname = self.rlocale.date_displayer.long_months[int(month)]
@@ -1006,7 +1007,7 @@ class WebCalReport(Report):
note = self.database.get_note_from_gramps_id(note)
note = self.get_note_format(note)
- # table foot section
+ # table foot section
cal_foot = Html("tfoot")
monthly_calendar += cal_foot
@@ -1022,7 +1023,7 @@ class WebCalReport(Report):
# send calendar page to web output
# and close the file
- self.XHTMLWriter(webcal, open_file)
+ self.xhtmlwriter(webcal, open_file)
step()
@@ -1058,7 +1059,8 @@ class WebCalReport(Report):
# generate progress pass for "Year At A Glance"
with self._user.progress(_("Web Calendar Report"),
- _('Creating Year At A Glance calendar'), 12) as step:
+ _('Creating Year At A Glance calendar'),
+ 12) as step:
open_file = self.create_file('fullyearlinked', str(year))
@@ -1079,9 +1081,10 @@ class WebCalReport(Report):
body += self.month_navigation(nr_up, year, "fullyearlinked", True)
msg = (self._('This calendar is meant to give you access '
- 'to all your data at a glance compressed into one page. '
- 'Clicking on a date will take you to a page that shows all'
- ' the events for that date, if there are any.\n'))
+ 'to all your data at a glance compressed into one '
+ 'page. Clicking on a date will take you to a page '
+ 'that shows all the events for that date, if there '
+ 'are any.\n'))
# page description
content = Html("div", class_="content", id="YearGlance")
@@ -1106,7 +1109,7 @@ class WebCalReport(Report):
# send calendar page to web output
# and close the file
- self.XHTMLWriter(yearglance, open_file)
+ self.xhtmlwriter(yearglance, open_file)
def one_day(self, event_date, fname_date, day_list):
"""
@@ -1145,7 +1148,7 @@ class WebCalReport(Report):
currentsection = _dd.long_months[month]
body += self.month_navigation(nr_up, year, currentsection, True)
- # set date display as in user prevferences
+ # set date display as in user preferences
content = Html("div", class_="content", id="OneDay")
body += content
evt = fname_date[:8]
@@ -1160,7 +1163,7 @@ class WebCalReport(Report):
url = event[1] + self.ext
prevd = Date(int(event[1][:4]), int(event[1][4:6]),
int(event[1][6:]))
- my_title = Html("a", _escape("<"), href=url,
+ my_title = Html("a", html_escape("<"), href=url,
title=self.rlocale.get_date(prevd))
else:
my_title = Html(' ')
@@ -1169,7 +1172,7 @@ class WebCalReport(Report):
url = event[2] + self.ext
nextd = Date(int(event[2][:4]), int(event[2][4:6]),
int(event[2][6:]))
- my_title += Html("a", _escape(">"), href=url,
+ my_title += Html("a", html_escape(">"), href=url,
title=self.rlocale.get_date(nextd))
else:
my_title += Html(' ')
@@ -1183,8 +1186,8 @@ class WebCalReport(Report):
# list the events
ordered = Html("ol")
content += ordered
- for (nyears, date, text, event, age_at_death,
- dead_event_date) in day_list:
+ for (dummy_nyears, dummy_date, text, event, dummy_age_at_death,
+ dummy_dead_event_date) in day_list:
ordered += Html("li", text,
inline=False if event == 'Anniversary' else True)
@@ -1195,7 +1198,7 @@ class WebCalReport(Report):
# send calendar page to web output
# and close the file
- self.XHTMLWriter(oneday, one_day_file)
+ self.xhtmlwriter(oneday, one_day_file)
def build_url_fname_html(self, fname, subdir=None, prefix=None):
"""
@@ -1279,7 +1282,7 @@ class WebCalReport(Report):
people = self.filter.apply(db, people, user=self._user)
with self._user.progress(_("Web Calendar Report"),
- _("Reading database..."), len(people)) as step:
+ _("Reading database..."), len(people)) as step:
for person in map(db.get_person_from_handle, people):
step()
@@ -1298,13 +1301,13 @@ class WebCalReport(Report):
death_date = death_event.get_date_object()
person_death = death_date
if (birth_date != Date() and birth_date.is_valid()
- and death_date):
+ and death_date):
age_at_death = death_date - birth_date
age_at_death = age_at_death.format(dlocale=self.rlocale)
# determine birthday information???
if (self.birthday and birth_date is not Date()
- and birth_date.is_valid()):
+ and birth_date.is_valid()):
birth_date = gregorian(birth_date)
year = birth_date.get_year()
@@ -1333,11 +1336,11 @@ class WebCalReport(Report):
if mother_handle == person.handle:
if father_handle:
father = db.get_person_from_handle(
- father_handle)
+ father_handle)
if father is not None:
father_surname = _regular_surname(
- person.gender,
- father.get_primary_name())
+ person.gender,
+ father.get_primary_name())
short_name = self.get_name(person, father_surname)
alive = probably_alive(person, db, prob_alive_date)
if (self.alive and alive) or not self.alive:
@@ -1346,10 +1349,10 @@ class WebCalReport(Report):
if self.link_to_narweb:
prfx = self.narweb_prefix
text = str(Html("a", short_name,
- href=self.build_url_fname_html(
- person.handle,
- "ppl",
- prefix=prfx)))
+ href=self.build_url_fname_html(
+ person.handle,
+ "ppl",
+ prefix=prfx)))
else:
text = short_name
if age_at_death is None:
@@ -1360,6 +1363,36 @@ class WebCalReport(Report):
self.add_day_item(text, year, month, day,
'Birthday',
age_at_death, person_death)
+ death_event = get_death_or_fallback(db, person)
+ if death_event:
+ death_date = death_event.get_date_object()
+ else:
+ death_date = None
+ #primary_name = person.primary_name
+ #name = Name(primary_name)
+ if self.death_anniv and death_date:
+ year = death_date.get_year() or this_year
+ month = death_date.get_month()
+ day = death_date.get_day()
+
+ short_name = self.get_name(person)
+ prob_alive_date = Date(this_year, month, day)
+ alive = probably_alive(person, db, prob_alive_date)
+ if (self.alive and alive) or not self.alive:
+ # add link to NarrativeWeb
+ if self.link_to_narweb:
+ prfx = self.narweb_prefix
+ navpfx = self.build_url_fname_html(person.handle,
+ "ppl",
+ prefix=prfx)
+ text = str(Html("a", short_name, href=navpfx))
+ else:
+ text = short_name
+ self.add_day_item(text, year, month, day, 'Death',
+ age_at_death, death_date)
+ #print('Death date for %s %s/%s/%s' % (short_name, day,
+ # month, year),
+ # age_at_death)
# add anniversary if requested
if self.anniv:
@@ -1381,10 +1414,10 @@ class WebCalReport(Report):
spouse_death = Date()
if death_ref:
death_event = db.get_event_from_handle(
- death_ref.ref)
+ death_ref.ref)
death_date = death_event.get_date_object()
if (death_date != Date() and
- death_date.is_valid()):
+ death_date.is_valid()):
spouse_death = death_date
first_died = Date()
if person_death == Date():
@@ -1401,7 +1434,7 @@ class WebCalReport(Report):
if marriage_event:
event_date = marriage_event.get_date_object()
if (event_date is not Date() and
- event_date.is_valid()):
+ event_date.is_valid()):
event_date = gregorian(event_date)
year = event_date.get_year()
month = event_date.get_month()
@@ -1417,14 +1450,16 @@ class WebCalReport(Report):
dlocale=self.rlocale)
if self.link_to_narweb:
+ prefx = self.narweb_prefix
+ reference = self.build_url_fname_html(
+ spouse_handle, 'ppl',
+ prefix=prefx)
spouse_name = str(Html("a", spouse_name,
- href=self.build_url_fname_html(
- spouse_handle, 'ppl',
- prefix=self.narweb_prefix)))
+ href=reference))
+ href1 = self.build_url_fname_html(
+ person.handle, 'ppl', prefix=prefx)
short_name = str(Html("a", short_name,
- href=self.build_url_fname_html(
- person.handle, 'ppl',
- prefix=self.narweb_prefix)))
+ href=href1))
alive1 = probably_alive(person, db,
prob_alive_date)
@@ -1435,9 +1470,10 @@ class WebCalReport(Report):
if ((self.alive and alive1
and alive2) or not self.alive):
- mg = self._('%(spouse)s and %(person)s')
- text = mg % {'spouse' : spouse_name,
- 'person' : short_name}
+ spse = self._('%(spouse)s and'
+ ' %(person)s')
+ text = spse % {'spouse' : spouse_name,
+ 'person' : short_name}
self.add_day_item(text, year, month,
day, 'Anniversary',
@@ -1455,12 +1491,13 @@ class WebCalReport(Report):
with Html("div", id="footer", role="Footer-End") as footer:
# Display date as user set in preferences
+ date = self.rlocale.date_displayer.display(Today())
+ bhtml = ''
msg = self._('Generated by %(gramps_home_html_start)s'
- 'Gramps%(html_end)s on %(date)s') % {
- 'gramps_home_html_start' :
- '',
- 'html_end' : '',
- 'date' : self.rlocale.date_displayer.display(Today())}
+ 'Gramps%(html_end)s on %(date)s') % {
+ 'gramps_home_html_start' : bhtml,
+ 'html_end' : '',
+ 'date' : date}
footer += Html("p", msg, id='createdate')
copy_nr = self.copy
@@ -1482,7 +1519,7 @@ class WebCalReport(Report):
# return footer to its callers
return footer
- def XHTMLWriter(self, page, open_file):
+ def xhtmlwriter(self, page, open_file):
"""
This function is simply to make the web page look pretty and readable
It is not for the browser, but for us, humans
@@ -1580,7 +1617,7 @@ class WebCalReport(Report):
# send calendar page to web output
# and close the file
- self.XHTMLWriter(index, output_file)
+ self.xhtmlwriter(index, output_file)
# -----------------------------------------------------------------------------
# WebCalOptions; Creates the Menu
@@ -1600,6 +1637,7 @@ class WebCalOptions(MenuReportOptions):
self.__multiyear = None
self.__start_year = None
self.__end_year = None
+ self.__after_year = None
def add_menu_options(self, menu):
"""
@@ -1608,8 +1646,8 @@ class WebCalOptions(MenuReportOptions):
self.__add_report_options(menu)
self.__add_report2_options(menu)
self.__add_content_options(menu)
- self.__add_notes_options(menu)
self.__add_advanced_options(menu)
+ self.__add_notes_options(menu)
def __add_report_options(self, menu):
"""
@@ -1619,9 +1657,9 @@ class WebCalOptions(MenuReportOptions):
dbname = self.__db.get_dbname()
default_dir = dbname + "_WEBCAL"
- target = DestinationOption(_("Destination"),
- os.path.join(config.get('paths.website-directory'),
- default_dir))
+ target = DestinationOption(
+ _("Destination"),
+ os.path.join(config.get('paths.website-directory'), default_dir))
target.set_help(_("The destination directory for the web files"))
target.set_directory_entry(True)
menu.add_option(category_name, "target", target)
@@ -1632,7 +1670,7 @@ class WebCalOptions(MenuReportOptions):
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(
- _("Select filter to restrict people that appear on calendar"))
+ _("Select filter to restrict people that appear on calendar"))
menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed)
@@ -1656,8 +1694,8 @@ class WebCalOptions(MenuReportOptions):
menu.add_option(category_name, "cright", cright)
css_list = sorted([(CSS[key]["translation"], CSS[key]["id"])
- for key in list(CSS.keys())
- if CSS[key]["user"]])
+ for key in list(CSS.keys())
+ if CSS[key]["user"]])
css = EnumeratedListOption(_('StyleSheet'), css_list[0][1])
for css_item in css_list:
css.add_item(css_item[1], css_item[0])
@@ -1680,8 +1718,8 @@ class WebCalOptions(MenuReportOptions):
default = ind
break
name_format = EnumeratedListOption(_("Name format"),
- fmt_list[default][0])
- for num, name, fmt_str, act in fmt_list:
+ fmt_list[default][0])
+ for num, name, dummy_fmt_str, dummy_act in fmt_list:
name_format.add_item(num, name)
name_format.set_help(_("Select the format to display names"))
menu.add_option(category_name, "name_format", name_format)
@@ -1729,15 +1767,17 @@ class WebCalOptions(MenuReportOptions):
holiday_table = libholiday.HolidayTable()
countries = holiday_table.get_countries()
countries.sort()
- if (len(countries) == 0 or
- (len(countries) > 0 and countries[0] != '')):
+ #if (len(countries) == 0 or
+ # (len(countries) > 0 and countries[0] != '')):
+ if (not countries or
+ (countries and countries[0] != '')):
countries.insert(0, '')
count = 0
for cntry in countries:
country.add_item(count, cntry)
count += 1
country.set_help(_("Holidays will be included for the selected "
- "country"))
+ "country"))
menu.add_option(category_name, "country", country)
# Default selection ????
@@ -1750,9 +1790,9 @@ class WebCalOptions(MenuReportOptions):
maiden_name = EnumeratedListOption(_("Birthday surname"), "own")
maiden_name.add_item('spouse_first', _("Wives use husband's surname "
- "(from first family listed)"))
+ "(from first family listed)"))
maiden_name.add_item('spouse_last', _("Wives use husband's surname "
- "(from last family listed)"))
+ "(from last family listed)"))
maiden_name.add_item("own", _("Wives use their own surname"))
maiden_name.set_help(_("Select married women's displayed surname"))
menu.add_option(category_name, "maiden_name", maiden_name)
@@ -1761,17 +1801,9 @@ class WebCalOptions(MenuReportOptions):
default_link = '../../' + dbname + "_NAVWEB/index.html"
home_link = StringOption(_('Home link'), default_link)
home_link.set_help(_("The link to be included to direct the user to "
- "the main page of the web site"))
+ "the main page of the web site"))
menu.add_option(category_name, "home_link", home_link)
- birthdays = BooleanOption(_("Include birthdays"), True)
- birthdays.set_help(_("Include birthdays in the calendar"))
- menu.add_option(category_name, "birthdays", birthdays)
-
- anniversaries = BooleanOption(_("Include anniversaries"), True)
- anniversaries.set_help(_("Include anniversaries in the calendar"))
- menu.add_option(category_name, "anniversaries", anniversaries)
-
def __add_notes_options(self, menu):
"""
Options on the "Months Notes" tabs.
@@ -1847,11 +1879,34 @@ class WebCalOptions(MenuReportOptions):
makeoneday.set_help(_('Whether to create one day pages or not'))
menu.add_option(category_name, 'makeoneday', makeoneday)
+ birthdays = BooleanOption(_("Include birthdays"), True)
+ birthdays.set_help(_("Include birthdays in the calendar"))
+ menu.add_option(category_name, "birthdays", birthdays)
+
+ anniversaries = BooleanOption(_("Include anniversaries"), True)
+ anniversaries.set_help(_("Include anniversaries in the calendar"))
+ menu.add_option(category_name, "anniversaries", anniversaries)
+
+ anniversaries = BooleanOption(_('Include death dates'), False)
+ anniversaries.set_help(_('Include death anniversaries in the calendar'))
+ menu.add_option(category_name, 'death_anniv', anniversaries)
+
self.__links = BooleanOption(_('Link to Narrated Web Report'), False)
self.__links.set_help(_('Whether to link data to web report or not'))
menu.add_option(category_name, 'link_to_narweb', self.__links)
self.__links.connect('value-changed', self.__links_changed)
+ today = Today()
+ default_before = config.get('behavior.max-age-prob-alive')
+ self.__after_year = NumberOption(_('Show data only after year'),
+ (today.get_year() - default_before),
+ 0, today.get_year())
+ self.__after_year.set_help(_("Show data only after this year."
+ " Default is current year - "
+ " 'maximum age probably alive' which is "
+ "defined in the dates preference tab."))
+ menu.add_option(category_name, 'after_year', self.__after_year)
+
dbname = self.__db.get_dbname()
default_prefix = '../../' + dbname + "_NAVWEB/"
self.__prefix = StringOption(_('Link prefix'), default_prefix)
@@ -1912,6 +1967,7 @@ def _regular_surname(sex, name):
"""
Returns a name string built from the components of the Name instance.
"""
+ dummy_gender = sex
surname = name.get_surname()
suffix = name.get_suffix()
if suffix:
@@ -2026,7 +2082,7 @@ def get_day_list(event_date, holiday_list, bday_anniv_list, rlocale=glocale):
translated_date = rlocale.get_date(dead_event_date)
mess = trans_date % {'death_date' : translated_date}
age = ", %s %s (%s)" % (
- death_symbol, mess, age_at_death)
+ death_symbol, mess, age_at_death)
else:
# TRANSLATORS: expands to smth like "12 years old",
# where "12 years" is already localized to your language
@@ -2034,18 +2090,25 @@ def get_day_list(event_date, holiday_list, bday_anniv_list, rlocale=glocale):
date_y = date.get_year()
trans_date = trans_text("Born %(birth_date)s.")
old_date = trans_text('%s old')
- tranlated_date = rlocale.get_date(dead_event_date)
- age += old_date % str(age_str) if date_y != 0 else \
- trans_date % {
- 'birth_date' : translated_date}
+ translated_date = rlocale.get_date(dead_event_date)
+ age += old_date % (str(age_str) if (date_y != 0)
+ else trans_date % {
+ 'birth_date' : translated_date})
txt_str = (text + age + '')
+ # a death
+ if event == 'Death':
+ txt_str = (text + ', '
+ + (_('%s since death') % str(age_str) if nyears
+ else _('death'))
+ + '')
+
# an anniversary
elif event == "Anniversary":
if nyears == 0:
txt_str = trans_text('%(couple)s, wedding') % {
- 'couple' : text}
+ 'couple' : text}
else:
if age_at_death is not None:
age = '%s %s' % (trans_text("Married"), age_at_death)