Remove custom_column usages from an earlier commit.
This commit is contained in:
parent
0b709f7dfb
commit
0926ae530c
24
cps/db.py
24
cps/db.py
|
@ -31,7 +31,7 @@ from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
|
||||||
|
|
||||||
session = None
|
session = None
|
||||||
cc_exceptions = ['comments', 'float', 'composite', 'series']
|
cc_exceptions = ['datetime', 'comments', 'float', 'composite', 'series']
|
||||||
cc_classes = {}
|
cc_classes = {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ def setup_db(config):
|
||||||
# conn.connection.create_function('upper', 1, ucase)
|
# conn.connection.create_function('upper', 1, ucase)
|
||||||
|
|
||||||
if not cc_classes:
|
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 = []
|
cc_ids = []
|
||||||
books_custom_column_links = {}
|
books_custom_column_links = {}
|
||||||
|
@ -366,7 +366,7 @@ def setup_db(config):
|
||||||
ForeignKey('custom_column_' + str(row.id) + '.id'),
|
ForeignKey('custom_column_' + str(row.id) + '.id'),
|
||||||
primary_key=True)
|
primary_key=True)
|
||||||
)
|
)
|
||||||
cc_ids.append([row.id, row.datatype, row.normalized])
|
cc_ids.append([row.id, row.datatype])
|
||||||
if row.datatype == 'bool':
|
if row.datatype == 'bool':
|
||||||
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
||||||
'id': Column(Integer, primary_key=True),
|
'id': Column(Integer, primary_key=True),
|
||||||
|
@ -377,11 +377,6 @@ def setup_db(config):
|
||||||
'id': Column(Integer, primary_key=True),
|
'id': Column(Integer, primary_key=True),
|
||||||
'book': Column(Integer, ForeignKey('books.id')),
|
'book': Column(Integer, ForeignKey('books.id')),
|
||||||
'value': Column(Integer)}
|
'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:
|
else:
|
||||||
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
||||||
'id': Column(Integer, primary_key=True),
|
'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)
|
cc_classes[row.id] = type(str('Custom_Column_' + str(row.id)), (Base,), ccdict)
|
||||||
|
|
||||||
for cc_id in cc_ids:
|
for cc_id in cc_ids:
|
||||||
normalized = cc_id[2]
|
if (cc_id[1] == 'bool') or (cc_id[1] == 'int'):
|
||||||
if (not normalized):
|
|
||||||
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
|
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
|
||||||
primaryjoin=(
|
primaryjoin=(
|
||||||
Books.id == cc_classes[cc_id[0]].book),
|
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]],
|
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
|
||||||
secondary=books_custom_column_links[cc_id[0]],
|
secondary=books_custom_column_links[cc_id[0]],
|
||||||
backref='books'))
|
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
|
global session
|
||||||
|
|
34
cps/kobo.py
34
cps/kobo.py
|
@ -371,42 +371,18 @@ def create_metadata(book):
|
||||||
return metadata
|
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):
|
def reading_state(book):
|
||||||
# TODO: Make the state custom columns configurable.
|
# TODO: Implement
|
||||||
# Possibly use calibre-web User db instead of the Calibre metadata.db?
|
|
||||||
reading_state = {
|
reading_state = {
|
||||||
"StatusInfo": {
|
# "StatusInfo": {
|
||||||
"LastModified": get_single_cc_value(book, "lastreadtimestamp"),
|
# "LastModified": get_single_cc_value(book, "lastreadtimestamp"),
|
||||||
"Status": get_single_cc_value(book, "reading_status"),
|
# "Status": get_single_cc_value(book, "reading_status"),
|
||||||
}
|
# }
|
||||||
# TODO: CurrentBookmark, Location
|
# TODO: CurrentBookmark, Location
|
||||||
}
|
}
|
||||||
return reading_state
|
return reading_state
|
||||||
|
|
||||||
|
|
||||||
# def get_shelves(book):
|
|
||||||
# shelves = get_custom_column_values(book, "myshelves")
|
|
||||||
# return shelves
|
|
||||||
|
|
||||||
|
|
||||||
@kobo.route(
|
@kobo.route(
|
||||||
"/<book_uuid>/<horizontal>/<vertical>/<jpeg_quality>/<monochrome>/image.jpg"
|
"/<book_uuid>/<horizontal>/<vertical>/<jpeg_quality>/<monochrome>/image.jpg"
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,3 +32,6 @@ rarfile>=2.7
|
||||||
# other
|
# other
|
||||||
natsort>=2.2.0
|
natsort>=2.2.0
|
||||||
git+https://github.com/OzzieIsaacs/comicapi.git@5346716578b2843f54d522f44d01bc8d25001d24#egg=comicapi
|
git+https://github.com/OzzieIsaacs/comicapi.git@5346716578b2843f54d522f44d01bc8d25001d24#egg=comicapi
|
||||||
|
|
||||||
|
# Unsupported/Experimental backblaze integration for Kobo endpoint.
|
||||||
|
b2sdk>=1.0.2,<2.0.0
|
||||||
|
|
|
@ -13,5 +13,4 @@ SQLAlchemy>=1.1.0
|
||||||
tornado>=4.1
|
tornado>=4.1
|
||||||
Wand>=0.4.4
|
Wand>=0.4.4
|
||||||
unidecode>=0.04.19
|
unidecode>=0.04.19
|
||||||
b2sdk>=1.0.2,<2.0.0
|
|
||||||
jsonschema>=3.2.0
|
jsonschema>=3.2.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user