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")