mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-26 10:00:37 +00:00
Merging ignorable columns
This commit is contained in:
parent
ee5870c6cf
commit
8745d65ff6
@ -62,7 +62,10 @@
|
|||||||
<label for="config_random_books">{{_('No. of random books to show')}}</label>
|
<label for="config_random_books">{{_('No. of random books to show')}}</label>
|
||||||
<input type="number" min="1" max="30" class="form-control" name="config_random_books" id="config_random_books" value="{% if content.config_random_books != None %}{{ content.config_random_books }}{% endif %}" autocomplete="off">
|
<input type="number" min="1" max="30" class="form-control" name="config_random_books" id="config_random_books" value="{% if content.config_random_books != None %}{{ content.config_random_books }}{% endif %}" autocomplete="off">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="config_columns_to_ignore">{{_('Regular expression for ignoring columns')}}</label>
|
||||||
|
<input type="text" class="form-control" name="config_columns_to_ignore" id="config_columns_to_ignore" value="{% if content.config_columns_to_ignore != None %}{{ content.config_columns_to_ignore }}{% endif %}" autocomplete="off">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="config_title_regex">{{_('Regular expression for title sorting')}}</label>
|
<label for="config_title_regex">{{_('Regular expression for title sorting')}}</label>
|
||||||
<input type="text" class="form-control" name="config_title_regex" id="config_title_regex" value="{% if content.config_title_regex != None %}{{ content.config_title_regex }}{% endif %}" autocomplete="off">
|
<input type="text" class="form-control" name="config_title_regex" id="config_title_regex" value="{% if content.config_title_regex != None %}{{ content.config_title_regex }}{% endif %}" autocomplete="off">
|
||||||
|
@ -275,6 +275,7 @@ class Settings(Base):
|
|||||||
config_google_drive_folder = Column(String)
|
config_google_drive_folder = Column(String)
|
||||||
config_google_drive_calibre_url_base = Column(String)
|
config_google_drive_calibre_url_base = Column(String)
|
||||||
config_google_drive_watch_changes_response = Column(String)
|
config_google_drive_watch_changes_response = Column(String)
|
||||||
|
config_columns_to_ignore = Column(String)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
pass
|
pass
|
||||||
@ -310,7 +311,7 @@ class Config:
|
|||||||
self.config_google_drive_watch_changes_response = json.loads(data.config_google_drive_watch_changes_response)
|
self.config_google_drive_watch_changes_response = json.loads(data.config_google_drive_watch_changes_response)
|
||||||
else:
|
else:
|
||||||
self.config_google_drive_watch_changes_response=None
|
self.config_google_drive_watch_changes_response=None
|
||||||
|
self.config_columns_to_ignore = data.config_columns_to_ignore
|
||||||
if (self.config_calibre_dir is not None and not self.config_use_google_drive) or os.path.exists(self.config_calibre_dir + '/metadata.db'):
|
if (self.config_calibre_dir is not None and not self.config_use_google_drive) or os.path.exists(self.config_calibre_dir + '/metadata.db'):
|
||||||
self.db_configured = True
|
self.db_configured = True
|
||||||
else:
|
else:
|
||||||
@ -406,6 +407,12 @@ def migrate_Database():
|
|||||||
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_calibre_url_base` INTEGER DEFAULT 0")
|
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_calibre_url_base` INTEGER DEFAULT 0")
|
||||||
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_folder` String DEFAULT ''")
|
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_folder` String DEFAULT ''")
|
||||||
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_watch_changes_response` String DEFAULT ''")
|
conn.execute("ALTER TABLE Settings ADD column `config_google_drive_watch_changes_response` String DEFAULT ''")
|
||||||
|
try:
|
||||||
|
session.query(exists().where(Settings.config_columns_to_ignore)).scalar()
|
||||||
|
except exc.OperationalError:
|
||||||
|
conn = engine.connect()
|
||||||
|
conn.execute("ALTER TABLE Settings ADD column `config_columns_to_ignore` String DEFAULT ''")
|
||||||
|
session.commit()
|
||||||
try:
|
try:
|
||||||
session.query(exists().where(Settings.config_default_role)).scalar()
|
session.query(exists().where(Settings.config_default_role)).scalar()
|
||||||
session.commit()
|
session.commit()
|
||||||
|
13
cps/web.py
13
cps/web.py
@ -1124,7 +1124,16 @@ def show_book(id):
|
|||||||
except:
|
except:
|
||||||
entries.languages[index].language_name = _(
|
entries.languages[index].language_name = _(
|
||||||
isoLanguages.get(part3=entries.languages[index].lang_code).name)
|
isoLanguages.get(part3=entries.languages[index].lang_code).name)
|
||||||
cc = db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all()
|
tmpcc = db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all()
|
||||||
|
|
||||||
|
if config.config_columns_to_ignore:
|
||||||
|
cc=[]
|
||||||
|
for col in tmpcc:
|
||||||
|
r= re.compile(config.config_columns_to_ignore)
|
||||||
|
if r.match(col.label):
|
||||||
|
c.append(col)
|
||||||
|
else:
|
||||||
|
cc=tmpcc
|
||||||
book_in_shelfs = []
|
book_in_shelfs = []
|
||||||
shelfs = ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == id).all()
|
shelfs = ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == id).all()
|
||||||
for entry in shelfs:
|
for entry in shelfs:
|
||||||
@ -1964,6 +1973,8 @@ def configuration_helper(origin):
|
|||||||
reboot_required = True
|
reboot_required = True
|
||||||
if "config_calibre_web_title" in to_save:
|
if "config_calibre_web_title" in to_save:
|
||||||
content.config_calibre_web_title = to_save["config_calibre_web_title"]
|
content.config_calibre_web_title = to_save["config_calibre_web_title"]
|
||||||
|
if "config_columns_to_ignore" in to_save:
|
||||||
|
content.config_columns_to_ignore = to_save["config_columns_to_ignore"]
|
||||||
if "config_title_regex" in to_save:
|
if "config_title_regex" in to_save:
|
||||||
if content.config_title_regex != to_save["config_title_regex"]:
|
if content.config_title_regex != to_save["config_title_regex"]:
|
||||||
content.config_title_regex = to_save["config_title_regex"]
|
content.config_title_regex = to_save["config_title_regex"]
|
||||||
|
Loading…
Reference in New Issue
Block a user