0002204: Narrative Web report "restrict living" is different than Gramps 2.x
svn: r10786
This commit is contained in:
parent
367e3b73a7
commit
0b70388483
@ -331,7 +331,8 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
||||
# If the restrict flag is set, apply the LivingProxyDb
|
||||
if option_box.restrict:
|
||||
self.dbase = gen.proxy.LivingProxyDb(
|
||||
self.dbase, gen.proxy.LivingProxyDb.MODE_RESTRICT)
|
||||
self.dbase,
|
||||
gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
||||
|
||||
# If the filter returned by cfilter is not empty, apply the
|
||||
# FilterProxyDb
|
||||
|
@ -88,7 +88,7 @@ def export_data(database, filename, person, option_box, callback=None):
|
||||
|
||||
if restrict:
|
||||
database = gen.proxy.LivingProxyDb(
|
||||
database, gen.proxy.LivingProxyDb.MODE_RESTRICT)
|
||||
database, gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
||||
|
||||
if not option_box.cfilter.is_empty():
|
||||
database = gen.proxy.FilterProxyDb(database, option_box.cfilter)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -50,8 +50,9 @@ class LivingProxyDb(ProxyDbBase):
|
||||
A proxy to a Gramps database. This proxy will act like a Gramps database,
|
||||
but all living people will be hidden from the user.
|
||||
"""
|
||||
MODE_EXCLUDE = 0
|
||||
MODE_RESTRICT = 1
|
||||
MODE_EXCLUDE_ALL = 0
|
||||
MODE_INCLUDE_LAST_NAME_ONLY = 1
|
||||
MODE_INCLUDE_FULL_NAME_ONLY = 2
|
||||
|
||||
def __init__(self, dbase, mode, current_year=None, years_after_death=0):
|
||||
"""
|
||||
@ -60,9 +61,11 @@ class LivingProxyDb(ProxyDbBase):
|
||||
@param dbase: The database to be a proxy for
|
||||
@type dbase: DbBase
|
||||
@param mode: The method for handling living people.
|
||||
LivingProxyDb.MODE_EXCLUDE will remove living people altogether.
|
||||
LivingProxyDb.MODE_RESTRICT will remove all information and change
|
||||
their given name to "Living".
|
||||
LivingProxyDb.MODE_EXCLUDE_ALL will remove living people altogether.
|
||||
LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY will remove all information
|
||||
and change their given name to "Living".
|
||||
LivingProxyDb.MODE_INCLUDE_FULL_NAME_ONLY will remove all information
|
||||
but leave the entire name intact.
|
||||
@type mode: int
|
||||
@param current_year: The current year to use for living determination.
|
||||
If None is supplied, the current year will be found from the system.
|
||||
@ -87,10 +90,10 @@ class LivingProxyDb(ProxyDbBase):
|
||||
"""
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
if person and self.__is_living(person):
|
||||
if self.mode == self.MODE_EXCLUDE:
|
||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
||||
person = None
|
||||
elif self.mode == self.MODE_RESTRICT:
|
||||
person = _restrict_person(person)
|
||||
else:
|
||||
person = self.__restrict_person(person)
|
||||
return person
|
||||
|
||||
def get_source_from_handle(self, handle):
|
||||
@ -151,10 +154,10 @@ class LivingProxyDb(ProxyDbBase):
|
||||
"""
|
||||
person = self.db.get_person_from_gramps_id(val)
|
||||
if self.__is_living(person):
|
||||
if self.mode == self.MODE_EXCLUDE:
|
||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
||||
return None
|
||||
else:
|
||||
return _restrict_person(person)
|
||||
return self.__restrict_person(person)
|
||||
else:
|
||||
return person
|
||||
|
||||
@ -215,12 +218,12 @@ class LivingProxyDb(ProxyDbBase):
|
||||
the database. If sort_handles is True, the list is sorted by surnames
|
||||
"""
|
||||
handles = []
|
||||
if self.mode == self.MODE_EXCLUDE:
|
||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
||||
for handle in self.db.get_person_handles(sort_handles):
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
if not self.__is_living(person):
|
||||
handles.append(handle)
|
||||
elif self.mode == self.MODE_RESTRICT:
|
||||
else:
|
||||
handles = self.db.get_person_handles(sort_handles)
|
||||
return handles
|
||||
|
||||
@ -398,7 +401,7 @@ class LivingProxyDb(ProxyDbBase):
|
||||
father = self.db.get_person_from_handle(father_handle)
|
||||
if self.__is_living(father):
|
||||
parent_is_living = True
|
||||
if self.mode == self.MODE_EXCLUDE:
|
||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
||||
family.set_father_handle(None)
|
||||
|
||||
mother_handle = family.get_mother_handle()
|
||||
@ -406,14 +409,14 @@ class LivingProxyDb(ProxyDbBase):
|
||||
mother = self.db.get_person_from_handle(mother_handle)
|
||||
if self.__is_living(mother):
|
||||
parent_is_living = True
|
||||
if self.mode == self.MODE_EXCLUDE:
|
||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
||||
family.set_mother_handle(None)
|
||||
|
||||
if parent_is_living:
|
||||
# Clear all events for families where a parent is living.
|
||||
family.set_event_ref_list([])
|
||||
|
||||
if self.mode == self.MODE_EXCLUDE:
|
||||
if self.mode == self.MODE_EXCLUDE_ALL:
|
||||
for child_ref in family.get_child_ref_list():
|
||||
child_handle = child_ref.get_reference_handle()
|
||||
child = self.db.get_person_from_handle(child_handle)
|
||||
@ -422,9 +425,10 @@ class LivingProxyDb(ProxyDbBase):
|
||||
|
||||
return family
|
||||
|
||||
def _restrict_person(person):
|
||||
def __restrict_person(self, person):
|
||||
"""
|
||||
Remove information from a person and replace the first name with "Living".
|
||||
Remove information from a person and replace the first name with
|
||||
"Living".
|
||||
"""
|
||||
new_person = Person()
|
||||
new_name = Name()
|
||||
@ -435,7 +439,10 @@ def _restrict_person(person):
|
||||
new_name.set_display_as(old_name.get_display_as())
|
||||
new_name.set_surname_prefix(old_name.get_surname_prefix())
|
||||
new_name.set_type(old_name.get_type())
|
||||
if self.mode == self.MODE_INCLUDE_LAST_NAME_ONLY:
|
||||
new_name.set_first_name(_(u'Living'))
|
||||
else: # self.mode == self.MODE_INCLUDE_FULL_NAME_ONLY
|
||||
new_name.set_first_name(old_name.get_first_name())
|
||||
new_name.set_patronymic(old_name.get_patronymic())
|
||||
new_name.set_surname(old_name.get_surname())
|
||||
new_name.set_privacy(old_name.get_privacy())
|
||||
|
@ -94,6 +94,7 @@ from gen.lib.eventroletype import EventRoleType
|
||||
# constants
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_INCLUDE_LIVING_VALUE = 99 # Arbitrary number
|
||||
_NARRATIVE = "narrative.css"
|
||||
_NARRATIVEPRINT = "narrative-print.css"
|
||||
_NAME_COL = 3
|
||||
@ -2486,14 +2487,9 @@ class NavWebReport(Report):
|
||||
livinginfo = self.options['living']
|
||||
yearsafterdeath = self.options['yearsafterdeath']
|
||||
|
||||
if livinginfo == LivingProxyDb.MODE_EXCLUDE:
|
||||
if livinginfo != _INCLUDE_LIVING_VALUE:
|
||||
self.database = LivingProxyDb(self.database,
|
||||
LivingProxyDb.MODE_EXCLUDE,
|
||||
None,
|
||||
yearsafterdeath)
|
||||
elif livinginfo == LivingProxyDb.MODE_RESTRICT:
|
||||
self.database = LivingProxyDb(self.database,
|
||||
LivingProxyDb.MODE_RESTRICT,
|
||||
livinginfo,
|
||||
None,
|
||||
yearsafterdeath)
|
||||
|
||||
@ -2936,7 +2932,6 @@ class NavWebOptions(MenuReportOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
__INCLUDE_LIVING_VALUE = 99 # Arbitrary number
|
||||
|
||||
def __init__(self, name, dbase):
|
||||
self.__db = dbase
|
||||
@ -3101,10 +3096,15 @@ class NavWebOptions(MenuReportOptions):
|
||||
menu.add_option(category_name, 'incpriv', incpriv)
|
||||
|
||||
self.__living = EnumeratedListOption(_("Living People"),
|
||||
self.__INCLUDE_LIVING_VALUE )
|
||||
self.__living.add_item(LivingProxyDb.MODE_EXCLUDE, _("Exclude"))
|
||||
self.__living.add_item(LivingProxyDb.MODE_RESTRICT, _("Restrict"))
|
||||
self.__living.add_item(self.__INCLUDE_LIVING_VALUE, _("Include"))
|
||||
_INCLUDE_LIVING_VALUE )
|
||||
self.__living.add_item(LivingProxyDb.MODE_EXCLUDE_ALL,
|
||||
_("Exclude"))
|
||||
self.__living.add_item(LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY,
|
||||
_("Include Last Name Only"))
|
||||
self.__living.add_item(LivingProxyDb.MODE_INCLUDE_FULL_NAME_ONLY,
|
||||
_("Include Full Name Only"))
|
||||
self.__living.add_item(_INCLUDE_LIVING_VALUE,
|
||||
_("Include"))
|
||||
self.__living.set_help(_("How to handle living people"))
|
||||
menu.add_option(category_name, "living", self.__living)
|
||||
self.__living.connect('value-changed', self.__living_changed)
|
||||
@ -3198,7 +3198,7 @@ class NavWebOptions(MenuReportOptions):
|
||||
"""
|
||||
Handle a change in the living option
|
||||
"""
|
||||
if self.__living.get_value() == self.__INCLUDE_LIVING_VALUE:
|
||||
if self.__living.get_value() == _INCLUDE_LIVING_VALUE:
|
||||
self.__yearsafterdeath.set_available(False)
|
||||
else:
|
||||
self.__yearsafterdeath.set_available(True)
|
||||
|
@ -78,7 +78,7 @@ def writeData(database, filename, person, option_box, callback=None):
|
||||
|
||||
if restrict:
|
||||
database = gen.proxy.LivingProxyDb(
|
||||
database, gen.proxy.LivingProxyDb.MODE_RESTRICT)
|
||||
database, gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
||||
|
||||
if not option_box.cfilter.is_empty():
|
||||
database = gen.proxy.FilterProxyDb(database, option_box.cfilter)
|
||||
|
Loading…
Reference in New Issue
Block a user