* src/plugins/Calendar.py: Added relationships (feature #1086)

* src/PluginUtils/_MenuOptions.py: added get_center_person to filter option

2007-12-15  Douglas S. Blank  <dblank@cs.brynmawr.edu>


svn: r9510
This commit is contained in:
Doug Blank 2007-12-15 17:09:44 +00:00
parent 95c3645f13
commit 8712649b7d
3 changed files with 36 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2007-12-15 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/plugins/Calendar.py: Added relationships (feature #1086)
* src/PluginUtils/_MenuOptions.py: added get_center_person to filter option
2007-12-15 Douglas S. Blank <dblank@cs.brynmawr.edu> 2007-12-15 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/plugins/WebCal.py: Temp fixes to keep running (bug #1441) * src/plugins/WebCal.py: Temp fixes to keep running (bug #1441)

View File

@ -475,6 +475,9 @@ class FilterListOption(Option):
self.dialog.person = new_person self.dialog.person = new_person
self.update_gui_obj() self.update_gui_obj()
def get_center_person(self):
return self.dialog.person
def update_gui_obj(self): def update_gui_obj(self):
# update the gui object with new filter info # update the gui object with new filter info
from ReportBase import ReportUtils from ReportBase import ReportUtils

View File

@ -40,7 +40,7 @@ import os
import BaseDoc import BaseDoc
from BasicUtils import name_displayer from BasicUtils import name_displayer
from DateHandler import displayer from DateHandler import displayer
from PluginUtils import register_report from PluginUtils import register_report, relationship_class
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_DRAW, CATEGORY_TEXT, \ CATEGORY_DRAW, CATEGORY_TEXT, \
MODE_GUI, MODE_BKI, MODE_CLI MODE_GUI, MODE_BKI, MODE_CLI
@ -125,6 +125,12 @@ class Calendar(Report):
# report and graphic share most of the same code # report and graphic share most of the same code
# but calendar doesn't have a title # but calendar doesn't have a title
self.titletext = options_class.handler.options_dict['titletext'] self.titletext = options_class.handler.options_dict['titletext']
if 'relationships' in options_class.handler.options_dict.keys():
# report and graphic share most of the same code
# but calendar doesn't show relationships
self.relationships = options_class.handler.options_dict['relationships']
else:
self.relationships = False
self.year = options_class.handler.options_dict['year'] self.year = options_class.handler.options_dict['year']
self.name_format = options_class.handler.options_dict['name_format'][0] self.name_format = options_class.handler.options_dict['name_format'][0]
self.country = options_class.handler.options_dict['country'] self.country = options_class.handler.options_dict['country']
@ -137,9 +143,8 @@ class Calendar(Report):
self.text2 = options_class.handler.options_dict['text2'] self.text2 = options_class.handler.options_dict['text2']
self.text3 = options_class.handler.options_dict['text3'] self.text3 = options_class.handler.options_dict['text3']
self.filter = options_class.handler.options_dict['filter'] self.filter = options_class.handler.options_dict['filter']
self.filter.person = person self.filter_option = options_class.menu.get_option_by_name('filter')
name = name_displayer.display_formal(person) self.title = _("Calendar Report") #% name
self.title = _("Calendar for %s") % name
def get_name(self, person, maiden_name = None): def get_name(self, person, maiden_name = None):
""" Returns person's name, unless maiden_name given, unless married_name listed. """ """ Returns person's name, unless maiden_name given, unless married_name listed. """
@ -305,8 +310,11 @@ class Calendar(Report):
This method runs through the data, and collects the relevant dates This method runs through the data, and collects the relevant dates
and text. and text.
""" """
self.progress.set_pass(_('Filtering data...'), 0)
people = self.filter.apply(self.database, people = self.filter.apply(self.database,
self.database.get_person_handles(sort_handles=False)) self.database.get_person_handles(sort_handles=False))
center_person = self.filter_option.get_center_person()
rel_calc = relationship_class()
self.progress.set_pass(_('Filtering data...'), len(people)) self.progress.set_pass(_('Filtering data...'), len(people))
for person_handle in people: for person_handle in people:
self.progress.step() self.progress.step()
@ -343,7 +351,12 @@ class Calendar(Report):
if age >= 0: if age >= 0:
alive = probably_alive(person, self.database, make_date(self.year, month, day)) alive = probably_alive(person, self.database, make_date(self.year, month, day))
if ((self.alive and alive) or not self.alive): if ((self.alive and alive) or not self.alive):
self.add_day_item("%s, %d" % (short_name, age), self.year, month, day) comment = ""
if self.relationships:
relation = rel_calc.get_one_relationship(self.database, center_person, person)
if relation:
comment = " --- %s" % relation
self.add_day_item("%s, %d%s" % (short_name, age, comment), self.year, month, day)
if self.anniversaries: if self.anniversaries:
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()
for fhandle in family_list: for fhandle in family_list:
@ -420,6 +433,12 @@ class CalendarReport(Calendar):
self.doc.start_paragraph('BIR-Text3style') self.doc.start_paragraph('BIR-Text3style')
self.doc.write_text(str(self.text3)) self.doc.write_text(str(self.text3))
self.doc.end_paragraph() self.doc.end_paragraph()
if self.relationships:
center_person = self.filter_option.get_center_person()
name = center_person.get_primary_name()
self.doc.start_paragraph('BIR-Text3style')
self.doc.write_text(_("Relationships shown are to %s") % name_displayer.display_name(name))
self.doc.end_paragraph()
self.progress.set_pass(_('Formating months...'), 12) self.progress.set_pass(_('Formating months...'), 12)
for month in range(1, 13): for month in range(1, 13):
self.progress.step() self.progress.step()
@ -596,6 +615,11 @@ class CalendarReportOptions(CalendarOptions):
titletext.set_help(_("Title of calendar")) titletext.set_help(_("Title of calendar"))
menu.add_option(category_name,"titletext", titletext) menu.add_option(category_name,"titletext", titletext)
CalendarOptions.add_menu_options(self, menu) CalendarOptions.add_menu_options(self, menu)
category_name = _("Report Options")
option = BooleanOption(_("Include relationships to center person (slower)"),
False)
option.set_help(_("Include relationships to center person"))
menu.add_option(category_name,"relationships", option)
def make_default_style(self, default_style): def make_default_style(self, default_style):
""" Adds the options for the textual report """ """ Adds the options for the textual report """