6519: Add primary role option to event filter

This commit is contained in:
Nick Hall 2014-01-26 16:09:17 +00:00
parent f5b57d71fe
commit b8fa348621
4 changed files with 10 additions and 3 deletions

View File

@ -50,7 +50,8 @@ class HasEvent(HasEventBase):
_('Date:'),
_('Place:'),
_('Description:'),
_('Main Participants') ]
_('Main Participants:'),
_('Primary Role:') ]
name = _('People with the personal <event>')
description = _("Matches people with a personal event of a particular "
"value")
@ -59,7 +60,7 @@ class HasEvent(HasEventBase):
for event_ref in person.get_event_ref_list():
if not event_ref:
continue
if event_ref.role != EventRoleType.PRIMARY:
if int(self.list[5]) and event_ref.role != EventRoleType.PRIMARY:
# Only match primaries, no witnesses
continue
event = dbase.get_event_from_handle(event_ref.ref)

View File

@ -50,7 +50,8 @@ class HasEventBase(Rule):
_('Date:'),
_('Place:'),
_('Description:'),
_('Main Participants') ]
_('Main Participants:'),
_('Primary Role:') ]
name = _('Events matching parameters')
description = _("Matches events with particular parameters")
category = _('Event filters')

View File

@ -166,6 +166,9 @@ class FilterParser(handler.ContentHandler):
and len(self.a) == 3):
self.use_regex = self.a[2] == '1'
self.a = self.a[:2]
# HasEvent rule has extra primary role field in v3.4.7
if self.r == Rules.Person.HasEvent and len(self.a) == 5:
self.a.append('1')
#-------------------------------------------------------------------------
#

View File

@ -570,6 +570,8 @@ class EditRule(ManagedWindow.ManagedWindow):
elif v == _('Include Family events:'):
t = MyBoolean(_('Also family events where person is '
'wife/husband'))
elif v == _('Primary Role:'):
t = MyBoolean(_('Only include primary participants'))
elif v == _('Tag:'):
taglist = ['']
taglist = taglist + [tag.get_name() for tag in dbstate.db.iter_tags()]