custom ratings tables should not support notes

This commit is contained in:
Kovid Goyal 2023-08-18 11:31:13 +05:30
parent 53bfdd6ecf
commit a0b9a799d9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 3 deletions

View File

@ -57,18 +57,20 @@ class Table:
def __init__(self, name, metadata, link_table=None):
self.name, self.metadata = name, metadata
self.sort_alpha = metadata.get('is_multiple', False) and metadata.get('display', {}).get('sort_alpha', False)
dt = metadata['datatype']
# self.unserialize() maps values from the db to python objects
self.unserialize = {
'datetime': c_parse,
'bool': bool
}.get(metadata['datatype'], None)
}.get(dt)
if name == 'authors':
# Legacy
self.unserialize = lambda x: x.replace('|', ',') if x else ''
self.link_table = (link_table if link_table else
'books_%s_link'%self.metadata['table'])
if self.supports_notes and dt == 'rating': # custom ratings table
self.supports_notes = False
def remove_books(self, book_ids, db):
return set()

View File

@ -297,7 +297,7 @@ def get_db_id(val, db, m, table, kmap, rid_map, allow_case_change,
table.asort_map[item_id] = aus
if hasattr(table, 'link_map'):
table.link_map[item_id] = ''
if table.supports_notes and isinstance(val, str):
if table.supports_notes:
db.unretire_note(table.name, item_id, val)
elif allow_case_change and val != table.id_map[item_id]:
case_changes[item_id] = val