mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-31 15:23:02 +00:00 
			
		
		
		
	Fixed read statu search with linked column in advanced search
This commit is contained in:
		
							
								
								
									
										0
									
								
								cps/__init__.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										0
									
								
								cps/__init__.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
								
								
									
										0
									
								
								cps/admin.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										0
									
								
								cps/admin.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
								
								
									
										0
									
								
								cps/redirect.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										0
									
								
								cps/redirect.py
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @@ -24,6 +24,7 @@ from flask_babel import format_date | |||||||
| from flask_babel import gettext as _ | from flask_babel import gettext as _ | ||||||
| from sqlalchemy.sql.expression import func, not_, and_, or_, text, true | from sqlalchemy.sql.expression import func, not_, and_, or_, text, true | ||||||
| from sqlalchemy.sql.functions import coalesce | from sqlalchemy.sql.functions import coalesce | ||||||
|  | from sqlalchemy import exists | ||||||
|  |  | ||||||
| from . import logger, db, calibre_db, config, ub | from . import logger, db, calibre_db, config, ub | ||||||
| from .usermanagement import login_required_if_no_ano | from .usermanagement import login_required_if_no_ano | ||||||
| @@ -92,16 +93,16 @@ def adv_search_custom_columns(cc, term, q): | |||||||
|                     db.cc_classes[c.id].value <= custom_high)) |                     db.cc_classes[c.id].value <= custom_high)) | ||||||
|         else: |         else: | ||||||
|             custom_query = term.get('custom_column_' + str(c.id)) |             custom_query = term.get('custom_column_' + str(c.id)) | ||||||
|             if c.datatype == 'bool' and custom_query != "Any": |             if c.datatype == 'bool': | ||||||
|                 # ToDo: |                 if custom_query != "Any": | ||||||
|                 q = q.filter(coalesce(db.cc_classes[config.config_read_column].value, False) != True) |                     if custom_query == "": | ||||||
|                 q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( |                         q = q.filter(~getattr(db.Books, 'custom_column_' + str(c.id)). | ||||||
|                     db.cc_classes[c.id].value == (custom_query == "True"))) |                                      any(db.cc_classes[c.id].value >= 0)) | ||||||
|  |                     else: | ||||||
|  |                         q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( | ||||||
|  |                             db.cc_classes[c.id].value == bool(custom_query == "True"))) | ||||||
|             elif custom_query != '' and custom_query is not None: |             elif custom_query != '' and custom_query is not None: | ||||||
|                 if c.datatype == 'int' or c.datatype == 'float': |                 if c.datatype == 'rating': | ||||||
|                     q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( |  | ||||||
|                         db.cc_classes[c.id].value == custom_query)) |  | ||||||
|                 elif c.datatype == 'rating': |  | ||||||
|                     q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( |                     q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( | ||||||
|                         db.cc_classes[c.id].value == int(float(custom_query) * 2))) |                         db.cc_classes[c.id].value == int(float(custom_query) * 2))) | ||||||
|                 else: |                 else: | ||||||
| @@ -140,10 +141,10 @@ def adv_search_read_status(read_status): | |||||||
|             db_filter = coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED |             db_filter = coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED | ||||||
|     else: |     else: | ||||||
|         try: |         try: | ||||||
|             if read_status == "True": |             if read_status == "": | ||||||
|                 db_filter = db.cc_classes[config.config_read_column].value == True |                 db_filter = coalesce(db.cc_classes[config.config_read_column].value, 2) == 2 | ||||||
|             else: |             else: | ||||||
|                 db_filter = coalesce(db.cc_classes[config.config_read_column].value, False) != True |                 db_filter = db.cc_classes[config.config_read_column].value == bool(read_status == "True") | ||||||
|         except (KeyError, AttributeError, IndexError): |         except (KeyError, AttributeError, IndexError): | ||||||
|             log.error("Custom Column No.{} does not exist in calibre database".format(config.config_read_column)) |             log.error("Custom Column No.{} does not exist in calibre database".format(config.config_read_column)) | ||||||
|             flash(_("Custom Column No.%(column)d does not exist in calibre database", |             flash(_("Custom Column No.%(column)d does not exist in calibre database", | ||||||
| @@ -299,6 +300,10 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): | |||||||
|             if column_high: |             if column_high: | ||||||
|                 search_term.extend(["{} <= {}".format(c.name,column_high)]) |                 search_term.extend(["{} <= {}".format(c.name,column_high)]) | ||||||
|                 cc_present = True |                 cc_present = True | ||||||
|  |         elif c.datatype == "bool": | ||||||
|  |             if term.get('custom_column_' + str(c.id)) != "Any": | ||||||
|  |                 search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) | ||||||
|  |                 cc_present = True | ||||||
|         elif term.get('custom_column_' + str(c.id)): |         elif term.get('custom_column_' + str(c.id)): | ||||||
|             search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) |             search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) | ||||||
|             cc_present = True |             cc_present = True | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ozzie Isaacs
					Ozzie Isaacs