diff --git a/src/Filters/Rules/Person/_HasAddress.py b/src/Filters/Rules/Person/_HasAddress.py index 422d05584..6722e5a7f 100755 --- a/src/Filters/Rules/Person/_HasAddress.py +++ b/src/Filters/Rules/Person/_HasAddress.py @@ -45,7 +45,7 @@ class HasAddress(Rule): labels = [ _('Number of instances:'), _('Number must be:')] name = _('People with address') - description = _("Matches peoplewith certain number of personal address") + description = _("Matches people with certain number of personal address") category = _('General filters') diff --git a/src/Filters/Rules/Person/_HasAssociation.py b/src/Filters/Rules/Person/_HasAssociation.py index 441528bc3..788cedb88 100755 --- a/src/Filters/Rules/Person/_HasAssociation.py +++ b/src/Filters/Rules/Person/_HasAssociation.py @@ -43,9 +43,27 @@ from Filters.Rules import Rule class HasAssociation(Rule): """Rule that checks for a person with a personal association""" - name = _('People with association') - description = _("Matches people with association") + labels = [ _('Number of instances:'), _('Number must be:')] + name = _('People with association') + description = _("Matches people with certain number of association") category = _('General filters') + 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, person): return len( person.get_person_ref_list()) > 0 + 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