slight tweaks to calendat-type reports
This commit is contained in:
@@ -72,7 +72,7 @@ class Report(object):
|
|||||||
self._ = locale.translation.gettext
|
self._ = locale.translation.gettext
|
||||||
self._get_date = locale.get_date
|
self._get_date = locale.get_date
|
||||||
self._get_type = locale.get_type
|
self._get_type = locale.get_type
|
||||||
self._dd = locale.date_displayer
|
self._ldd = locale.date_displayer
|
||||||
self._name_display = NameDisplay(locale) # a legacy/historical name
|
self._name_display = NameDisplay(locale) # a legacy/historical name
|
||||||
self._name_display.set_name_format(self.database.name_formats)
|
self._name_display.set_name_format(self.database.name_formats)
|
||||||
fmt_default = config.get('preferences.name-format')
|
fmt_default = config.get('preferences.name-format')
|
||||||
|
@@ -51,7 +51,7 @@ from gramps.gen.plug.report import utils as ReportUtils
|
|||||||
from gramps.gen.plug.report import MenuReportOptions
|
from gramps.gen.plug.report import MenuReportOptions
|
||||||
from gramps.gen.plug.report import stdoptions
|
from gramps.gen.plug.report import stdoptions
|
||||||
from gramps.gen.utils.alive import probably_alive
|
from gramps.gen.utils.alive import probably_alive
|
||||||
from gramps.gen.datehandler import displayer as _dd
|
from gramps.gen.datehandler import displayer as date_displayer
|
||||||
from gramps.gen.lib import (Date, EventRoleType, EventType, Name, NameType,
|
from gramps.gen.lib import (Date, EventRoleType, EventType, Name, NameType,
|
||||||
Person, Surname)
|
Person, Surname)
|
||||||
from gramps.gen.lib.date import gregorian
|
from gramps.gen.lib.date import gregorian
|
||||||
@@ -213,7 +213,7 @@ class Calendar(Report):
|
|||||||
pnumbers = style_sheet.get_paragraph_style("CAL-Numbers")
|
pnumbers = style_sheet.get_paragraph_style("CAL-Numbers")
|
||||||
numpos = pt2cm(pnumbers.get_font().get_size())
|
numpos = pt2cm(pnumbers.get_font().get_size())
|
||||||
ptext1style = style_sheet.get_paragraph_style("CAL-Text1style")
|
ptext1style = style_sheet.get_paragraph_style("CAL-Text1style")
|
||||||
long_days = self._dd.long_days
|
long_days = self._ldd.long_days
|
||||||
|
|
||||||
self.doc.start_page()
|
self.doc.start_page()
|
||||||
width = self.doc.get_usable_width()
|
width = self.doc.get_usable_width()
|
||||||
@@ -230,7 +230,7 @@ class Calendar(Report):
|
|||||||
# http://gramps-project.org/wiki/index.php?title=Translating_Gramps#Translating_dates
|
# http://gramps-project.org/wiki/index.php?title=Translating_Gramps#Translating_dates
|
||||||
# to learn how to select proper inflection for your language.
|
# to learn how to select proper inflection for your language.
|
||||||
title = self._("{long_month} {year}").format(
|
title = self._("{long_month} {year}").format(
|
||||||
long_month = self._dd.long_months[month],
|
long_month = self._ldd.long_months[month],
|
||||||
year = year
|
year = year
|
||||||
).capitalize()
|
).capitalize()
|
||||||
mark = IndexMark(title, INDEX_TYPE_TOC, 2)
|
mark = IndexMark(title, INDEX_TYPE_TOC, 2)
|
||||||
@@ -465,15 +465,11 @@ class CalendarOptions(MenuReportOptions):
|
|||||||
add_option = partial(menu.add_option, category_name)
|
add_option = partial(menu.add_option, category_name)
|
||||||
##########################
|
##########################
|
||||||
|
|
||||||
year = NumberOption(_("Year of calendar"), time.localtime()[0],
|
|
||||||
1000, 3000)
|
|
||||||
year.set_help(_("Year of calendar"))
|
|
||||||
add_option("year", year)
|
|
||||||
|
|
||||||
self.__filter = FilterOption(_("Filter"), 0)
|
self.__filter = FilterOption(_("Filter"), 0)
|
||||||
self.__filter.set_help(
|
self.__filter.set_help(
|
||||||
_("Select filter to restrict people that appear on calendar"))
|
_("Select filter to restrict people that appear on calendar"))
|
||||||
add_option("filter", self.__filter)
|
add_option("filter", self.__filter)
|
||||||
|
self.__filter.connect('value-changed', self.__filter_changed)
|
||||||
|
|
||||||
self.__pid = PersonOption(_("Center Person"))
|
self.__pid = PersonOption(_("Center Person"))
|
||||||
self.__pid.set_help(_("The center person for the report"))
|
self.__pid.set_help(_("The center person for the report"))
|
||||||
@@ -487,6 +483,22 @@ class CalendarOptions(MenuReportOptions):
|
|||||||
|
|
||||||
stdoptions.add_private_data_option(menu, category_name)
|
stdoptions.add_private_data_option(menu, category_name)
|
||||||
|
|
||||||
|
alive = BooleanOption(_("Include only living people"), True)
|
||||||
|
alive.set_help(_("Include only living people in the calendar"))
|
||||||
|
add_option("alive", alive)
|
||||||
|
|
||||||
|
stdoptions.add_localization_option(menu, category_name)
|
||||||
|
|
||||||
|
##########################
|
||||||
|
category_name = _("Content Options")
|
||||||
|
add_option = partial(menu.add_option, category_name)
|
||||||
|
##########################
|
||||||
|
|
||||||
|
year = NumberOption(_("Year of calendar"), time.localtime()[0],
|
||||||
|
1000, 3000)
|
||||||
|
year.set_help(_("Year of calendar"))
|
||||||
|
add_option("year", year)
|
||||||
|
|
||||||
country = EnumeratedListOption(_("Country for holidays"), 0)
|
country = EnumeratedListOption(_("Country for holidays"), 0)
|
||||||
holiday_table = libholiday.HolidayTable()
|
holiday_table = libholiday.HolidayTable()
|
||||||
countries = holiday_table.get_countries()
|
countries = holiday_table.get_countries()
|
||||||
@@ -502,7 +514,7 @@ class CalendarOptions(MenuReportOptions):
|
|||||||
add_option("country", country)
|
add_option("country", country)
|
||||||
|
|
||||||
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
||||||
long_days = _dd.long_days
|
long_days = date_displayer.long_days
|
||||||
for count in range(1, 8):
|
for count in range(1, 8):
|
||||||
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
|
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
|
||||||
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
|
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
|
||||||
@@ -516,10 +528,6 @@ class CalendarOptions(MenuReportOptions):
|
|||||||
maiden_name.set_help(_("Select married women's displayed surname"))
|
maiden_name.set_help(_("Select married women's displayed surname"))
|
||||||
add_option("maiden_name", maiden_name)
|
add_option("maiden_name", maiden_name)
|
||||||
|
|
||||||
alive = BooleanOption(_("Include only living people"), True)
|
|
||||||
alive.set_help(_("Include only living people in the calendar"))
|
|
||||||
add_option("alive", alive)
|
|
||||||
|
|
||||||
birthdays = BooleanOption(_("Include birthdays"), True)
|
birthdays = BooleanOption(_("Include birthdays"), True)
|
||||||
birthdays.set_help(_("Include birthdays in the calendar"))
|
birthdays.set_help(_("Include birthdays in the calendar"))
|
||||||
add_option("birthdays", birthdays)
|
add_option("birthdays", birthdays)
|
||||||
@@ -528,10 +536,10 @@ class CalendarOptions(MenuReportOptions):
|
|||||||
anniversaries.set_help(_("Include anniversaries in the calendar"))
|
anniversaries.set_help(_("Include anniversaries in the calendar"))
|
||||||
add_option("anniversaries", anniversaries)
|
add_option("anniversaries", anniversaries)
|
||||||
|
|
||||||
stdoptions.add_localization_option(menu, category_name)
|
##########################
|
||||||
|
|
||||||
category_name = _("Text Options")
|
category_name = _("Text Options")
|
||||||
add_option = partial(menu.add_option, _("Text Options"))
|
add_option = partial(menu.add_option, _("Text Options"))
|
||||||
|
##########################
|
||||||
|
|
||||||
text1 = StringOption(_("Text Area 1"), _(_TITLE1))
|
text1 = StringOption(_("Text Area 1"), _(_TITLE1))
|
||||||
text1.set_help(_("First line of text at bottom of calendar"))
|
text1.set_help(_("First line of text at bottom of calendar"))
|
||||||
@@ -557,6 +565,19 @@ class CalendarOptions(MenuReportOptions):
|
|||||||
name_format=nfv)
|
name_format=nfv)
|
||||||
self.__filter.set_filters(filter_list)
|
self.__filter.set_filters(filter_list)
|
||||||
|
|
||||||
|
def __filter_changed(self):
|
||||||
|
"""
|
||||||
|
Handle filter change. If the filter is not specific to a person,
|
||||||
|
disable the person option
|
||||||
|
"""
|
||||||
|
filter_value = self.__filter.get_value()
|
||||||
|
if filter_value in [1, 2, 3, 4]:
|
||||||
|
# Filters 1, 2, 3 and 4 rely on the center person
|
||||||
|
self.__pid.set_available(True)
|
||||||
|
else:
|
||||||
|
# The rest don't
|
||||||
|
self.__pid.set_available(False)
|
||||||
|
|
||||||
def make_my_style(self, default_style, name, description,
|
def make_my_style(self, default_style, name, description,
|
||||||
size=9, font=FONT_SERIF, justified ="left",
|
size=9, font=FONT_SERIF, justified ="left",
|
||||||
color=None, align=PARA_ALIGN_CENTER,
|
color=None, align=PARA_ALIGN_CENTER,
|
||||||
|
@@ -56,7 +56,7 @@ from gramps.gen.utils.alive import probably_alive
|
|||||||
import gramps.plugins.lib.libholiday as libholiday
|
import gramps.plugins.lib.libholiday as libholiday
|
||||||
|
|
||||||
# localization for BirthdayOptions only!!
|
# localization for BirthdayOptions only!!
|
||||||
from gramps.gen.datehandler import displayer as _dd
|
from gramps.gen.datehandler import displayer as date_displayer
|
||||||
|
|
||||||
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
|
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
|
||||||
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
|
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
|
||||||
@@ -431,6 +431,10 @@ class BirthdayOptions(MenuReportOptions):
|
|||||||
|
|
||||||
stdoptions.add_private_data_option(menu, category_name)
|
stdoptions.add_private_data_option(menu, category_name)
|
||||||
|
|
||||||
|
alive = BooleanOption(_("Include only living people"), True)
|
||||||
|
alive.set_help(_("Include only living people in the report"))
|
||||||
|
menu.add_option(category_name, "alive", alive)
|
||||||
|
|
||||||
country = EnumeratedListOption(_("Country for holidays"), 0)
|
country = EnumeratedListOption(_("Country for holidays"), 0)
|
||||||
holiday_table = libholiday.HolidayTable()
|
holiday_table = libholiday.HolidayTable()
|
||||||
countries = holiday_table.get_countries()
|
countries = holiday_table.get_countries()
|
||||||
@@ -446,7 +450,7 @@ class BirthdayOptions(MenuReportOptions):
|
|||||||
menu.add_option(category_name, "country", country)
|
menu.add_option(category_name, "country", country)
|
||||||
|
|
||||||
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
||||||
long_days = _dd.long_days
|
long_days = date_displayer.long_days
|
||||||
for count in range(1, 8):
|
for count in range(1, 8):
|
||||||
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
|
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
|
||||||
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
|
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
|
||||||
@@ -460,10 +464,6 @@ class BirthdayOptions(MenuReportOptions):
|
|||||||
maiden_name.set_help(_("Select married women's displayed surname"))
|
maiden_name.set_help(_("Select married women's displayed surname"))
|
||||||
menu.add_option(category_name, "maiden_name", maiden_name)
|
menu.add_option(category_name, "maiden_name", maiden_name)
|
||||||
|
|
||||||
alive = BooleanOption(_("Include only living people"), True)
|
|
||||||
alive.set_help(_("Include only living people in the report"))
|
|
||||||
menu.add_option(category_name, "alive", alive)
|
|
||||||
|
|
||||||
birthdays = BooleanOption(_("Include birthdays"), True)
|
birthdays = BooleanOption(_("Include birthdays"), True)
|
||||||
birthdays.set_help(_("Include birthdays in the report"))
|
birthdays.set_help(_("Include birthdays in the report"))
|
||||||
menu.add_option(category_name, "birthdays", birthdays)
|
menu.add_option(category_name, "birthdays", birthdays)
|
||||||
|
@@ -63,7 +63,7 @@ from gramps.gen.plug.menu import (BooleanOption, NumberOption, StringOption,
|
|||||||
PersonOption, DestinationOption, NoteOption)
|
PersonOption, DestinationOption, NoteOption)
|
||||||
from gramps.gen.utils.config import get_researcher
|
from gramps.gen.utils.config import get_researcher
|
||||||
from gramps.gen.utils.alive import probably_alive
|
from gramps.gen.utils.alive import probably_alive
|
||||||
from gramps.gen.datehandler import displayer as _dd
|
from gramps.gen.datehandler import displayer as date_displayer
|
||||||
|
|
||||||
from gramps.gen.display.name import displayer as _nd
|
from gramps.gen.display.name import displayer as _nd
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
# each year will link to current month.
|
# each year will link to current month.
|
||||||
# this will always need an extension added
|
# this will always need an extension added
|
||||||
full_month_name = _dd.long_months[self.today.get_month() ]
|
full_month_name = date_displayer.long_months[self.today.get_month() ]
|
||||||
|
|
||||||
# Note. We use '/' here because it is a URL, not a OS dependent
|
# Note. We use '/' here because it is a URL, not a OS dependent
|
||||||
# pathname.
|
# pathname.
|
||||||
@@ -530,8 +530,9 @@ class WebCalReport(Report):
|
|||||||
# An optional link to a home page
|
# An optional link to a home page
|
||||||
if self.home_link:
|
if self.home_link:
|
||||||
navs.append((self.home_link, _('Home'), add_home))
|
navs.append((self.home_link, _('Home'), add_home))
|
||||||
navs.extend(
|
navs.extend((date_displayer.long_months[month],
|
||||||
(_dd.long_months[month], _dd.short_months[month], True) for month in range(1, 13) )
|
date_displayer.short_months[month], True)
|
||||||
|
for month in range(1, 13) )
|
||||||
|
|
||||||
# Add a link for year_glance() if requested
|
# Add a link for year_glance() if requested
|
||||||
navs.append(('fullyearlinked', _('Year Glance'), self.fullyear))
|
navs.append(('fullyearlinked', _('Year Glance'), self.fullyear))
|
||||||
@@ -597,8 +598,8 @@ class WebCalReport(Report):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# define names for long and short month names
|
# define names for long and short month names
|
||||||
full_month_name = _dd.long_months[month]
|
full_month_name = date_displayer.long_months[month]
|
||||||
abbr_month_name = _dd.short_months[month]
|
abbr_month_name = date_displayer.short_months[month]
|
||||||
|
|
||||||
# dow (day-of-week) uses Gramps numbering, sunday => 1, etc
|
# dow (day-of-week) uses Gramps numbering, sunday => 1, etc
|
||||||
start_dow = self.start_dow
|
start_dow = self.start_dow
|
||||||
@@ -620,7 +621,7 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
# Note. gen.datehandler has sunday => 1, monday => 2, etc
|
# Note. gen.datehandler has sunday => 1, monday => 2, etc
|
||||||
# We slice out the first empty element.
|
# We slice out the first empty element.
|
||||||
day_names = _dd.long_days # use self._dd.long_days when set_locale is used...
|
day_names = date_displayer.long_days # use self._ldd.long_days when set_locale is used ...
|
||||||
|
|
||||||
def __get_previous_month_day(year, month, day_col):
|
def __get_previous_month_day(year, month, day_col):
|
||||||
|
|
||||||
@@ -837,7 +838,7 @@ class WebCalReport(Report):
|
|||||||
_('Formatting months ...'), 12) as step:
|
_('Formatting months ...'), 12) as step:
|
||||||
|
|
||||||
for month in range(1, 13):
|
for month in range(1, 13):
|
||||||
cal_fname = _dd.long_months[month]
|
cal_fname = date_displayer.long_months[month]
|
||||||
of = self.create_file(cal_fname, str(year))
|
of = self.create_file(cal_fname, str(year))
|
||||||
|
|
||||||
# Add xml, doctype, meta and stylesheets
|
# Add xml, doctype, meta and stylesheets
|
||||||
@@ -850,7 +851,7 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
# Create Month Navigation Menu
|
# Create Month Navigation Menu
|
||||||
# identify currentsection for proper highlighting
|
# identify currentsection for proper highlighting
|
||||||
currentsection = _dd.long_months[month]
|
currentsection = date_displayer.long_months[month]
|
||||||
body += self.month_navigation(nr_up, year, currentsection, True)
|
body += self.month_navigation(nr_up, year, currentsection, True)
|
||||||
|
|
||||||
# build the calendar
|
# build the calendar
|
||||||
@@ -977,13 +978,13 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
# Create Month Navigation Menu
|
# Create Month Navigation Menu
|
||||||
# identify currentsection for proper highlighting
|
# identify currentsection for proper highlighting
|
||||||
currentsection = _dd.long_months[month]
|
currentsection = date_displayer.long_months[month]
|
||||||
body += self.month_navigation(nr_up, year, currentsection, True)
|
body += self.month_navigation(nr_up, year, currentsection, True)
|
||||||
|
|
||||||
# set date display as in user prevferences
|
# set date display as in user prevferences
|
||||||
content = Html("div", class_="content", id = "OneDay")
|
content = Html("div", class_="content", id = "OneDay")
|
||||||
body += content
|
body += content
|
||||||
content += Html("h3", _dd.display(event_date), inline = True)
|
content += Html("h3", date_displayer.display(event_date), inline = True)
|
||||||
|
|
||||||
# list the events
|
# list the events
|
||||||
ordered = Html("ol")
|
ordered = Html("ol")
|
||||||
@@ -1200,7 +1201,7 @@ class WebCalReport(Report):
|
|||||||
'gramps_home_html_start' :
|
'gramps_home_html_start' :
|
||||||
'<a href="' + URL_HOMEPAGE + '">' ,
|
'<a href="' + URL_HOMEPAGE + '">' ,
|
||||||
'html_end' : '</a>' ,
|
'html_end' : '</a>' ,
|
||||||
'date' : _dd.display(Today()) }
|
'date' : date_displayer.display(Today()) }
|
||||||
footer += Html("p", msg, id = 'createdate')
|
footer += Html("p", msg, id = 'createdate')
|
||||||
|
|
||||||
copy_nr = self.copy
|
copy_nr = self.copy
|
||||||
@@ -1360,6 +1361,10 @@ class WebCalOptions(MenuReportOptions):
|
|||||||
|
|
||||||
stdoptions.add_private_data_option(menu, category_name, default=False)
|
stdoptions.add_private_data_option(menu, category_name, default=False)
|
||||||
|
|
||||||
|
alive = BooleanOption(_("Include only living people"), True)
|
||||||
|
alive.set_help(_("Include only living people in the calendar"))
|
||||||
|
menu.add_option(category_name, "alive", alive)
|
||||||
|
|
||||||
ext = EnumeratedListOption(_("File extension"), ".html" )
|
ext = EnumeratedListOption(_("File extension"), ".html" )
|
||||||
for etype in _WEB_EXT:
|
for etype in _WEB_EXT:
|
||||||
ext.add_item(etype, etype)
|
ext.add_item(etype, etype)
|
||||||
@@ -1424,6 +1429,14 @@ class WebCalOptions(MenuReportOptions):
|
|||||||
"country"))
|
"country"))
|
||||||
menu.add_option(category_name, "country", country)
|
menu.add_option(category_name, "country", country)
|
||||||
|
|
||||||
|
# Default selection ????
|
||||||
|
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
||||||
|
for count in range(1, 8):
|
||||||
|
start_dow.add_item(count,
|
||||||
|
date_displayer.long_days[count].capitalize())
|
||||||
|
start_dow.set_help(_("Select the first day of the week for the calendar"))
|
||||||
|
menu.add_option(category_name, "start_dow", start_dow)
|
||||||
|
|
||||||
maiden_name = EnumeratedListOption(_("Birthday surname"), "own")
|
maiden_name = EnumeratedListOption(_("Birthday surname"), "own")
|
||||||
maiden_name.add_item('spouse_first', _("Wives use husband's surname "
|
maiden_name.add_item('spouse_first', _("Wives use husband's surname "
|
||||||
"(from first family listed)"))
|
"(from first family listed)"))
|
||||||
@@ -1433,13 +1446,6 @@ class WebCalOptions(MenuReportOptions):
|
|||||||
maiden_name.set_help(_("Select married women's displayed surname"))
|
maiden_name.set_help(_("Select married women's displayed surname"))
|
||||||
menu.add_option(category_name, "maiden_name", maiden_name)
|
menu.add_option(category_name, "maiden_name", maiden_name)
|
||||||
|
|
||||||
# Default selection ????
|
|
||||||
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
|
||||||
for count in range(1, 8):
|
|
||||||
start_dow.add_item(count, _dd.long_days[count].capitalize())
|
|
||||||
start_dow.set_help(_("Select the first day of the week for the calendar"))
|
|
||||||
menu.add_option(category_name, "start_dow", start_dow)
|
|
||||||
|
|
||||||
dbname = self.__db.get_dbname()
|
dbname = self.__db.get_dbname()
|
||||||
default_link = '../../' + dbname + "_NAVWEB/index.html"
|
default_link = '../../' + dbname + "_NAVWEB/index.html"
|
||||||
home_link = StringOption(_('Home link'), default_link)
|
home_link = StringOption(_('Home link'), default_link)
|
||||||
@@ -1447,10 +1453,6 @@ class WebCalOptions(MenuReportOptions):
|
|||||||
"the main page of the web site"))
|
"the main page of the web site"))
|
||||||
menu.add_option(category_name, "home_link", home_link)
|
menu.add_option(category_name, "home_link", home_link)
|
||||||
|
|
||||||
alive = BooleanOption(_("Include only living people"), True)
|
|
||||||
alive.set_help(_("Include only living people in the calendar"))
|
|
||||||
menu.add_option(category_name, "alive", alive)
|
|
||||||
|
|
||||||
birthdays = BooleanOption(_("Include birthdays"), True)
|
birthdays = BooleanOption(_("Include birthdays"), True)
|
||||||
birthdays.set_help(_("Include birthdays in the calendar"))
|
birthdays.set_help(_("Include birthdays in the calendar"))
|
||||||
menu.add_option(category_name, "birthdays", birthdays)
|
menu.add_option(category_name, "birthdays", birthdays)
|
||||||
|
Reference in New Issue
Block a user