1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-28 12:30:00 +00:00

Remove custom_column usages from an earlier commit.

This commit is contained in:
Michael Shavit 2019-12-07 21:08:53 -05:00
parent 0b709f7dfb
commit 0926ae530c
4 changed files with 12 additions and 50 deletions

View File

@ -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

View File

@ -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(
"/<book_uuid>/<horizontal>/<vertical>/<jpeg_quality>/<monochrome>/image.jpg"
)

View File

@ -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

View File

@ -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