From 19c21312d4acebd83982e16f2fd0774a2b131cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Wed, 5 Nov 2008 16:53:00 +0000 Subject: [PATCH] 2465: More rules according to User Interface Object tabs - use on name svn: r11256 --- src/Filters/Rules/Family/_HasLDS.py | 2 +- src/Filters/Rules/Person/_HasAddress.py | 27 +++++++++++++++++++++---- src/Filters/Rules/Person/_HasLDS.py | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Filters/Rules/Family/_HasLDS.py b/src/Filters/Rules/Family/_HasLDS.py index c511810cb..ae956a2bb 100755 --- a/src/Filters/Rules/Family/_HasLDS.py +++ b/src/Filters/Rules/Family/_HasLDS.py @@ -43,5 +43,5 @@ from Filters.Rules._HasLDSBase import HasLDSBase class HasLDS(HasLDSBase): """Rule that checks for family with a LDS event""" - name = _('Families with LDS events') + name = _('Families with LDS events') description = _("Matches families with a certain number of LDS events") diff --git a/src/Filters/Rules/Person/_HasAddress.py b/src/Filters/Rules/Person/_HasAddress.py index 1d9e87fcd..422d05584 100755 --- a/src/Filters/Rules/Person/_HasAddress.py +++ b/src/Filters/Rules/Person/_HasAddress.py @@ -43,9 +43,28 @@ from Filters.Rules import Rule class HasAddress(Rule): """Rule that checks for a person with a personal address""" - name = _('People with address') - description = _("Matches people with a personal address") + labels = [ _('Number of instances:'), _('Number must be:')] + name = _('People with address') + description = _("Matches peoplewith certain number of personal address") category = _('General filters') + - def apply(self, db, person): - return len( person.get_address_list()) > 0 + def prepare(self, db): + # things we want to do just once, not for every handle + if self.list[1] == _('lesser than'): + self.count_type = 0 + elif self.list[1] == _('greater than'): + self.count_type = 2 + else: + self.count_type = 1 # "equal to" + + self.userSelectedCount = int(self.list[0]) + + def apply(self, db, obj): + count = len( person.get_address_list()) + if self.count_type == 0: # "lesser than" + return count < self.userSelectedCount + elif self.count_type == 2: # "greater than" + return count > self.userSelectedCount + # "equal to" + return count == self.userSelectedCount diff --git a/src/Filters/Rules/Person/_HasLDS.py b/src/Filters/Rules/Person/_HasLDS.py index 8f28192eb..6d5a331a0 100755 --- a/src/Filters/Rules/Person/_HasLDS.py +++ b/src/Filters/Rules/Person/_HasLDS.py @@ -43,5 +43,5 @@ from Filters.Rules._HasLDSBase import HasLDSBase class HasLDS(HasLDSBase): """Rule that checks for a person with a LDS event""" - name = _('People with LDS events') + name = _('People with LDS events') description = _("Matches people with a certain number of LDS events")