|
|
@ -26,8 +26,11 @@ def title_sort(title):
|
|
|
|
title = title.replace(prep, '') + ', ' + prep
|
|
|
|
title = title.replace(prep, '') + ', ' + prep
|
|
|
|
return title.strip()
|
|
|
|
return title.strip()
|
|
|
|
|
|
|
|
|
|
|
|
def lowercase(string):
|
|
|
|
def lcase(s):
|
|
|
|
return string.lower()
|
|
|
|
return s.lower()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ucase(s):
|
|
|
|
|
|
|
|
return s.upper()
|
|
|
|
|
|
|
|
|
|
|
|
Base = declarative_base()
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
|
|
|
|
|
@ -128,7 +131,7 @@ class Tags(Base):
|
|
|
|
__tablename__ = 'tags'
|
|
|
|
__tablename__ = 'tags'
|
|
|
|
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = Column(String(collation = 'NOCASE'))
|
|
|
|
name = Column(String)
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, name):
|
|
|
|
def __init__(self, name):
|
|
|
|
self.name = name
|
|
|
|
self.name = name
|
|
|
@ -141,7 +144,7 @@ class Authors(Base):
|
|
|
|
__tablename__ = 'authors'
|
|
|
|
__tablename__ = 'authors'
|
|
|
|
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
name = Column(String(collation = 'U_NOCASE'))
|
|
|
|
name = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
link = Column(String)
|
|
|
|
link = Column(String)
|
|
|
|
|
|
|
|
|
|
|
@ -158,7 +161,7 @@ class Series(Base):
|
|
|
|
__tablename__ = 'series'
|
|
|
|
__tablename__ = 'series'
|
|
|
|
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
name = Column(String(collation = 'U_NOCASE'))
|
|
|
|
name = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, name, sort):
|
|
|
|
def __init__(self, name, sort):
|
|
|
@ -198,7 +201,7 @@ class Publishers(Base):
|
|
|
|
__tablename__ = 'publishers'
|
|
|
|
__tablename__ = 'publishers'
|
|
|
|
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
name = Column(String(collation = 'U_NOCASE'))
|
|
|
|
name = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, name,sort):
|
|
|
|
def __init__(self, name,sort):
|
|
|
@ -235,7 +238,7 @@ class Books(Base):
|
|
|
|
DEFAULT_PUBDATE = "0101-01-01 00:00:00+00:00"
|
|
|
|
DEFAULT_PUBDATE = "0101-01-01 00:00:00+00:00"
|
|
|
|
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
title = Column(String(collation = 'U_NOCASE'))
|
|
|
|
title = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
sort = Column(String)
|
|
|
|
author_sort = Column(String)
|
|
|
|
author_sort = Column(String)
|
|
|
|
timestamp = Column(String)
|
|
|
|
timestamp = Column(String)
|
|
|
@ -296,7 +299,6 @@ def setup_db():
|
|
|
|
global engine
|
|
|
|
global engine
|
|
|
|
global session
|
|
|
|
global session
|
|
|
|
global cc_classes
|
|
|
|
global cc_classes
|
|
|
|
global conn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if config.config_calibre_dir is None or config.config_calibre_dir == u'':
|
|
|
|
if config.config_calibre_dir is None or config.config_calibre_dir == u'':
|
|
|
|
content = ub.session.query(ub.Settings).first()
|
|
|
|
content = ub.session.query(ub.Settings).first()
|
|
|
@ -322,7 +324,8 @@ def setup_db():
|
|
|
|
ub.session.commit()
|
|
|
|
ub.session.commit()
|
|
|
|
config.loadSettings()
|
|
|
|
config.loadSettings()
|
|
|
|
conn.connection.create_function('title_sort', 1, title_sort)
|
|
|
|
conn.connection.create_function('title_sort', 1, title_sort)
|
|
|
|
conn.connection.create_function('lower', 1, lowercase)
|
|
|
|
conn.connection.create_function('lower', 1, lcase)
|
|
|
|
|
|
|
|
conn.connection.create_function('upper', 1, ucase)
|
|
|
|
|
|
|
|
|
|
|
|
if not cc_classes:
|
|
|
|
if not cc_classes:
|
|
|
|
cc = conn.execute("SELECT id, datatype FROM custom_columns")
|
|
|
|
cc = conn.execute("SELECT id, datatype FROM custom_columns")
|
|
|
@ -369,6 +372,6 @@ def setup_db():
|
|
|
|
|
|
|
|
|
|
|
|
# Base.metadata.create_all(engine)
|
|
|
|
# Base.metadata.create_all(engine)
|
|
|
|
Session = sessionmaker()
|
|
|
|
Session = sessionmaker()
|
|
|
|
Session.configure(bind=conn)
|
|
|
|
Session.configure(bind=engine)
|
|
|
|
session = Session()
|
|
|
|
session = Session()
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|