2465: More rules according to User Interface Object tabs - use <count> on name

svn: r11256
This commit is contained in:
Jérôme Rapinat 2008-11-05 16:53:00 +00:00
parent df3e7fb38d
commit 19c21312d4
3 changed files with 25 additions and 6 deletions

View File

@ -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 <count> LDS events')
description = _("Matches families with a certain number of LDS events")

View File

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

View File

@ -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 <count> LDS events')
description = _("Matches people with a certain number of LDS events")