#2465 clean up hasgallery rule, extend haslds rule

svn: r11253
This commit is contained in:
Benny Malengier 2008-11-05 12:44:15 +00:00
parent 642392bbf3
commit 7adff92c9c
6 changed files with 29 additions and 11 deletions

View File

@ -477,7 +477,7 @@ class EditRule(ManagedWindow.ManagedWindow):
t = MyInteger(0, 999)
elif v == _('Reference count must be:'):
t = MyLesserEqualGreater()
elif v == _('Number must be'):
elif v == _('Number must be:'):
t = MyLesserEqualGreater(1)
elif v == _('Number of generations:'):
t = MyInteger(1, 32)

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

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

View File

@ -40,8 +40,8 @@ from Filters.Rules import Rule
class HasGalleryBase(Rule):
"""Objects who have Media Object"""
labels = [ _('Number of instances:'), _('Number must be')]
name = _('Object with <count> Media reference')
labels = [ _('Number of instances:'), _('Number must be:')]
name = _('Object with <count> Media references')
description = _("Matches objects with certain number of items in the gallery")
category = _('General filters')

View File

@ -43,9 +43,27 @@ from Filters.Rules import Rule
class HasLDSBase(Rule):
"""Rule that checks for object with a LDS event"""
name = _('Object with LDS event')
description = _("Matches object with LDS event")
labels = [ _('Number of instances:'), _('Number must be:')]
name = _('Objects with LDS events')
description = _("Matches objects with LDS events")
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, obj):
return len( obj.get_lds_ord_list()) > 0
count = len( obj.get_lds_ord_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

@ -41,7 +41,7 @@ from Filters.Rules._Rule import Rule
class HasNoteBase(Rule):
"""Objects having notes"""
labels = [ _('Number of instances:'), _('Number must be')]
labels = [ _('Number of instances:'), _('Number must be:')]
name = _('Object with notes')
description = _("Matches objects that have a certain number of notes")
category = _('General filters')