From ca2bcc647d2a08bf2f6a281bce5e6698f6644f13 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sun, 19 Apr 2020 12:50:58 +0200 Subject: [PATCH] Handle read config Allow advance search Remove duplicate status on show --- cps/helper.py | 20 ++++++++++++-------- cps/web.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index 5e5bde29..29fd6308 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -804,16 +804,20 @@ def get_search_results(term): func.lower(db.Books.title).ilike("%" + term + "%") )).all() -def get_cc_columns(): +def get_cc_columns(filter_config_custom_read=False): tmpcc = db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all() + cc = [] + r = None if config.config_columns_to_ignore: - cc = [] - for col in tmpcc: - r = re.compile(config.config_columns_to_ignore) - if not r.match(col.name): - cc.append(col) - else: - cc = tmpcc + r = re.compile(config.config_columns_to_ignore) + + for col in tmpcc: + if filter_config_custom_read and config.config_read_column and config.config_read_column == col.id: + continue + if r and r.match(col.label): + continue + cc.append(col) + return cc def get_download_link(book_id, book_format): diff --git a/cps/web.py b/cps/web.py index bfb0ec5d..28b75b82 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1529,7 +1529,7 @@ def show_book(book_id): except UnknownLocaleError: entries.languages[index].language_name = _( isoLanguages.get(part3=entries.languages[index].lang_code).name) - cc = get_cc_columns() + cc = get_cc_columns(filter_config_custom_read=True) book_in_shelfs = [] shelfs = ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id).all() for entry in shelfs: