Fixes #1924675 [Rules editors: Set/unset on 'rating' invalid](https://bugs.launchpad.net/calibre/+bug/1924675)
This commit is contained in:
Kovid Goyal 2021-04-16 16:12:24 +05:30
commit 39b3e36e20
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -144,6 +144,10 @@ class Rule(object): # {{{
return "cmp(raw_field('%s'), %s, '%s', '%s', '%s')" % (col, val, lt, eq, gt) return "cmp(raw_field('%s'), %s, '%s', '%s', '%s')" % (col, val, lt, eq, gt)
def rating_condition(self, col, action, val): def rating_condition(self, col, action, val):
if action == 'is set':
return "test(field('%s'), '1', '')"%col
if action == 'is not set':
return "test(field('%s'), '', '1')"%col
lt, eq, gt = { lt, eq, gt = {
'eq': ('', '1', ''), 'eq': ('', '1', ''),
'lt': ('1', '', ''), 'lt': ('1', '', ''),