4921: Want a "Main Participants" entry in sidebar eventfilter; cleanup

svn: r17549
This commit is contained in:
Michiel Nauta 2011-05-22 12:40:37 +00:00
parent 521b8fa98d
commit c07c19dfe3
10 changed files with 26 additions and 17 deletions

View File

@ -20,6 +20,9 @@
# $Id$
"""
Filter rule to match families with a particular event.
"""
#-------------------------------------------------------------------------
#
# Standard Python modules
@ -45,15 +48,16 @@ class HasEvent(HasEventBase):
labels = [ _('Family event:'),
_('Date:'),
_('Place:'),
_('Description:') ]
_('Description:'),
_('Main Participants') ]
name = _('Families with the <event>')
description = _("Matches families with an event of a particular value")
def apply(self,db,family):
def apply(self, dbase, family):
for event_ref in family.get_event_ref_list():
if not event_ref:
continue
event = db.get_event_from_handle(event_ref.ref)
if HasEventBase.apply(self,db,event):
event = dbase.get_event_from_handle(event_ref.ref)
if HasEventBase.apply(self, dbase, event):
return True
return False

View File

@ -37,7 +37,7 @@ from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasEvent
# HasMedia
#
#-------------------------------------------------------------------------
class HasMedia(Rule):

View File

@ -37,7 +37,7 @@ from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasEvent
# HasNote
#
#-------------------------------------------------------------------------
class HasNote(Rule):

View File

@ -20,6 +20,9 @@
# $Id$
"""
Filter rule to match persons with a particular event.
"""
#-------------------------------------------------------------------------
#
# Standard Python modules
@ -46,18 +49,20 @@ class HasEvent(HasEventBase):
labels = [ _('Personal event:'),
_('Date:'),
_('Place:'),
_('Description:') ]
_('Description:'),
_('Main Participants') ]
name = _('People with the personal <event>')
description = _("Matches people with a personal event of a particular value")
description = _("Matches people with a personal event of a particular "
"value")
def apply(self,db,person):
def apply(self, dbase, person):
for event_ref in person.get_event_ref_list():
if not event_ref:
continue
if event_ref.role != EventRoleType.PRIMARY:
# Only match primaries, no witnesses
continue
event = db.get_event_from_handle(event_ref.ref)
if HasEventBase.apply(self,db,event):
event = dbase.get_event_from_handle(event_ref.ref)
if HasEventBase.apply(self, dbase, event):
return True
return False

View File

@ -38,7 +38,7 @@ from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasEvent
# HasPlace
#
#-------------------------------------------------------------------------
class HasPlace(Rule):

View File

@ -37,7 +37,7 @@ from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasEvent
# HasRepo
#
#-------------------------------------------------------------------------
class HasRepo(Rule):

View File

@ -36,7 +36,7 @@ from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasEvent
# HasSource
#
#-------------------------------------------------------------------------
class HasSource(Rule):

View File

@ -39,7 +39,7 @@ from Utils import get_participant_from_event
#-------------------------------------------------------------------------
#
# HasEvent
# HasEventBase
#
#-------------------------------------------------------------------------
class HasEventBase(Rule):

View File

@ -177,7 +177,7 @@ class FamilySidebarFilter(SidebarFilter):
generic_filter.add_rule(rule)
if etype:
rule = HasEvent([etype, u'', u'', u''])
rule = HasEvent([etype, u'', u'', u'', u''])
generic_filter.add_rule(rule)
if rtype:

View File

@ -206,7 +206,7 @@ class PersonSidebarFilter(SidebarFilter):
# Build an event filter if needed
if etype:
rule = HasEvent([etype, u'', u'', u''])
rule = HasEvent([etype, u'', u'', u'', u''])
generic_filter.add_rule(rule)
# Build birth event filter if needed