2465: More rules according to User Interface Object tabs - use the same logic as HasObject

svn: r11262
This commit is contained in:
Jérôme Rapinat 2008-11-06 08:43:47 +00:00
parent 245f04d4e9
commit b4e5ce5e32
2 changed files with 21 additions and 3 deletions

View File

@ -45,7 +45,7 @@ class HasAddress(Rule):
labels = [ _('Number of instances:'), _('Number must be:')]
name = _('People with <count> address')
description = _("Matches peoplewith certain number of personal address")
description = _("Matches people with certain number of personal address")
category = _('General filters')

View File

@ -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 <count> 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