2465: More rules according to User Interface Object tabs - (benny)
svn: r11249
This commit is contained in:
@@ -40,5 +40,5 @@ from Filters.Rules._HasGalleryBase import HasGalleryBase
|
||||
class HavePhotos(HasGalleryBase):
|
||||
"""Rule that checks for person who has media object reference"""
|
||||
|
||||
name = _('People with media')
|
||||
description = _("Matches people with media object in the gallery")
|
||||
name = _('People with <count> media')
|
||||
description = _("Matches people with a certain number of items in the gallery")
|
||||
|
||||
@@ -40,9 +40,27 @@ from Filters.Rules import Rule
|
||||
class HasGalleryBase(Rule):
|
||||
"""Objects who have Media Object"""
|
||||
|
||||
name = _('Object with Media reference')
|
||||
description = _("Matches objects with reference in the gallery")
|
||||
labels = [ _('Number of instances:'), _('Number must be')]
|
||||
name = _('Object with <count> Media reference')
|
||||
description = _("Matches objects with certain number of items in the gallery")
|
||||
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_media_list()) > 0
|
||||
count = len( obj.get_media_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
|
||||
|
||||
@@ -41,9 +41,28 @@ from Filters.Rules._Rule import Rule
|
||||
class HasNoteBase(Rule):
|
||||
"""Objects having notes"""
|
||||
|
||||
name = _('Object with note')
|
||||
description = _("Matches objects that have a note")
|
||||
labels = [ _('Number of instances:'), _('Number must be')]
|
||||
name = _('Object with notes')
|
||||
description = _("Matches objects that have a certain number of notes")
|
||||
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_note_list()) > 0
|
||||
count = len( obj.get_note_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
|
||||
|
||||
@@ -41,9 +41,27 @@ from Filters.Rules._Rule import Rule
|
||||
class HasSourceBase(Rule):
|
||||
"""Objects having notes"""
|
||||
|
||||
name = _('Objects with source')
|
||||
description = _("Matches objects that have a source")
|
||||
labels = [ _('Number of instances:'), _('Number must be')]
|
||||
name = _('Objects with <count> sources')
|
||||
description = _("Matches objects that have a certain number of sources")
|
||||
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_source_references()) > 0
|
||||
count = len(obj.get_source_references())
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user