From b8fa348621662d397cfc8817c4f0f0833f8ad27d Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sun, 26 Jan 2014 16:09:17 +0000 Subject: [PATCH] 6519: Add primary role option to event filter --- src/Filters/Rules/Person/_HasEvent.py | 5 +++-- src/Filters/Rules/_HasEventBase.py | 3 ++- src/Filters/_FilterParser.py | 3 +++ src/gui/filtereditor.py | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Filters/Rules/Person/_HasEvent.py b/src/Filters/Rules/Person/_HasEvent.py index 4092bd53e..180571035 100644 --- a/src/Filters/Rules/Person/_HasEvent.py +++ b/src/Filters/Rules/Person/_HasEvent.py @@ -50,7 +50,8 @@ class HasEvent(HasEventBase): _('Date:'), _('Place:'), _('Description:'), - _('Main Participants') ] + _('Main Participants:'), + _('Primary Role:') ] name = _('People with the personal ') 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) diff --git a/src/Filters/Rules/_HasEventBase.py b/src/Filters/Rules/_HasEventBase.py index 105788a6e..3c1eda028 100644 --- a/src/Filters/Rules/_HasEventBase.py +++ b/src/Filters/Rules/_HasEventBase.py @@ -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') diff --git a/src/Filters/_FilterParser.py b/src/Filters/_FilterParser.py index 3d551abdc..0525f2e82 100644 --- a/src/Filters/_FilterParser.py +++ b/src/Filters/_FilterParser.py @@ -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') #------------------------------------------------------------------------- # diff --git a/src/gui/filtereditor.py b/src/gui/filtereditor.py index 7eecd1b61..79305e51d 100644 --- a/src/gui/filtereditor.py +++ b/src/gui/filtereditor.py @@ -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()]