From 0926ae530ce3147e334209f9cb042e9d0a0d47e0 Mon Sep 17 00:00:00 2001 From: Michael Shavit Date: Sat, 7 Dec 2019 21:08:53 -0500 Subject: [PATCH] Remove custom_column usages from an earlier commit. --- cps/db.py | 24 ++++-------------------- cps/kobo.py | 34 +++++----------------------------- optional-requirements.txt | 3 +++ requirements.txt | 1 - 4 files changed, 12 insertions(+), 50 deletions(-) diff --git a/cps/db.py b/cps/db.py index dc280ad8..5765bf68 100755 --- a/cps/db.py +++ b/cps/db.py @@ -31,7 +31,7 @@ from sqlalchemy.ext.declarative import declarative_base session = None -cc_exceptions = ['comments', 'float', 'composite', 'series'] +cc_exceptions = ['datetime', 'comments', 'float', 'composite', 'series'] cc_classes = {} @@ -353,7 +353,7 @@ def setup_db(config): # conn.connection.create_function('upper', 1, ucase) if not cc_classes: - cc = conn.execute("SELECT id, datatype, normalized FROM custom_columns") + cc = conn.execute("SELECT id, datatype FROM custom_columns") cc_ids = [] books_custom_column_links = {} @@ -366,7 +366,7 @@ def setup_db(config): ForeignKey('custom_column_' + str(row.id) + '.id'), primary_key=True) ) - cc_ids.append([row.id, row.datatype, row.normalized]) + cc_ids.append([row.id, row.datatype]) if row.datatype == 'bool': ccdict = {'__tablename__': 'custom_column_' + str(row.id), 'id': Column(Integer, primary_key=True), @@ -377,11 +377,6 @@ def setup_db(config): 'id': Column(Integer, primary_key=True), 'book': Column(Integer, ForeignKey('books.id')), 'value': Column(Integer)} - elif not row.normalized: - ccdict = {'__tablename__': 'custom_column_' + str(row.id), - 'id': Column(Integer, primary_key=True), - 'book': Column(Integer, ForeignKey('books.id')), - 'value': Column(String)} else: ccdict = {'__tablename__': 'custom_column_' + str(row.id), 'id': Column(Integer, primary_key=True), @@ -389,8 +384,7 @@ def setup_db(config): cc_classes[row.id] = type(str('Custom_Column_' + str(row.id)), (Base,), ccdict) for cc_id in cc_ids: - normalized = cc_id[2] - if (not normalized): + if (cc_id[1] == 'bool') or (cc_id[1] == 'int'): setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]], primaryjoin=( Books.id == cc_classes[cc_id[0]].book), @@ -399,16 +393,6 @@ def setup_db(config): setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]], secondary=books_custom_column_links[cc_id[0]], backref='books')) - #for cc_id in cc_ids: - # if (cc_id[1] == 'bool') or (cc_id[1] == 'int'): - # setattr(Books, 'custom_column_' + str(cc_id[2]), relationship(cc_classes[cc_id[0]], - # primaryjoin=( - # Books.id == cc_classes[cc_id[0]].book), - # backref='books')) - # else: - # setattr(Books, 'custom_column_' + str(cc_id[2]), relationship(cc_classes[cc_id[0]], - # secondary=books_custom_column_links[cc_id[0]], - # backref='books')) global session diff --git a/cps/kobo.py b/cps/kobo.py index dce6869a..52ff8f2c 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -371,42 +371,18 @@ def create_metadata(book): return metadata -def get_single_cc_value(book, custom_column_name): - custom_column_values = get_custom_column_values(book, custom_column_name) - if custom_column_values: - return custom_column_values[0].value - return None - - -def get_custom_column_values(book, custom_column_name): - custom_column = ( - db.session.query(db.Custom_Columns) - .filter(db.Custom_Columns.label == custom_column_name) - .one() - ) - cc_string = "custom_column_" + str(custom_column.id) - - return getattr(book, cc_string) - - def reading_state(book): - # TODO: Make the state custom columns configurable. - # Possibly use calibre-web User db instead of the Calibre metadata.db? + # TODO: Implement reading_state = { - "StatusInfo": { - "LastModified": get_single_cc_value(book, "lastreadtimestamp"), - "Status": get_single_cc_value(book, "reading_status"), - } + # "StatusInfo": { + # "LastModified": get_single_cc_value(book, "lastreadtimestamp"), + # "Status": get_single_cc_value(book, "reading_status"), + # } # TODO: CurrentBookmark, Location } return reading_state -# def get_shelves(book): -# shelves = get_custom_column_values(book, "myshelves") -# return shelves - - @kobo.route( "//////image.jpg" ) diff --git a/optional-requirements.txt b/optional-requirements.txt index 605667d2..043a6943 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -32,3 +32,6 @@ rarfile>=2.7 # other natsort>=2.2.0 git+https://github.com/OzzieIsaacs/comicapi.git@5346716578b2843f54d522f44d01bc8d25001d24#egg=comicapi + +# Unsupported/Experimental backblaze integration for Kobo endpoint. +b2sdk>=1.0.2,<2.0.0 diff --git a/requirements.txt b/requirements.txt index d0c541a5..2ef6835d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,5 +13,4 @@ SQLAlchemy>=1.1.0 tornado>=4.1 Wand>=0.4.4 unidecode>=0.04.19 -b2sdk>=1.0.2,<2.0.0 jsonschema>=3.2.0