mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-30 23:03:02 +00:00 
			
		
		
		
	Fix lcase function
This commit is contained in:
		
							
								
								
									
										18
									
								
								cps/db.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								cps/db.py
									
									
									
									
									
								
							| @@ -546,14 +546,14 @@ class CalibreDB(threading.Thread): | ||||
|  | ||||
|     def get_typeahead(self, database, query, replace=('', ''), tag_filter=true()): | ||||
|         query = query or '' | ||||
|         self.session.connection().connection.connection.create_function("lower", 1, self.lcase) | ||||
|         self.session.connection().connection.connection.create_function("lower", 1, lcase) | ||||
|         entries = self.session.query(database).filter(tag_filter). \ | ||||
|             filter(func.lower(database.name).ilike("%" + query + "%")).all() | ||||
|         json_dumps = json.dumps([dict(name=r.name.replace(*replace)) for r in entries]) | ||||
|         return json_dumps | ||||
|  | ||||
|     def check_exists_book(self, authr, title): | ||||
|         self.session.connection().connection.connection.create_function("lower", 1, self.lcase) | ||||
|         self.session.connection().connection.connection.create_function("lower", 1, lcase) | ||||
|         q = list() | ||||
|         authorterms = re.split(r'\s*&\s*', authr) | ||||
|         for authorterm in authorterms: | ||||
| @@ -565,7 +565,7 @@ class CalibreDB(threading.Thread): | ||||
|     # read search results from calibre-database and return it (function is used for feed and simple search | ||||
|     def get_search_results(self, term): | ||||
|         term.strip().lower() | ||||
|         self.session.connection().connection.connection.create_function("lower", 1, self.lcase) | ||||
|         self.session.connection().connection.connection.create_function("lower", 1, lcase) | ||||
|         q = list() | ||||
|         authorterms = re.split("[, ]+", term) | ||||
|         for authorterm in authorterms: | ||||
| @@ -642,8 +642,10 @@ class CalibreDB(threading.Thread): | ||||
|         self.engine.dispose() | ||||
|         self.setup_db(config, app_db_path) | ||||
|  | ||||
|     def lcase(self, s): | ||||
|         try: | ||||
|             return unidecode.unidecode(s.lower()) | ||||
|         except Exception as e: | ||||
|             self.log.exception(e) | ||||
| def lcase(s): | ||||
|     try: | ||||
|         return unidecode.unidecode(s.lower()) | ||||
|     except Exception as e: | ||||
|         log = logger.create() | ||||
|         log.exception(e) | ||||
|         return s.lower() | ||||
|   | ||||
| @@ -590,7 +590,7 @@ def get_languages_json(): | ||||
| def get_matching_tags(): | ||||
|     tag_dict = {'tags': []} | ||||
|     q = calibre_db.session.query(db.Books) | ||||
|     calibre_db.session.connection().connection.connection.create_function("lower", 1, calibre_db.lcase) | ||||
|     calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase) | ||||
|     author_input = request.args.get('author_name') or '' | ||||
|     title_input = request.args.get('book_title') or '' | ||||
|     include_tag_inputs = request.args.getlist('include_tag') or '' | ||||
| @@ -1020,7 +1020,7 @@ def search(): | ||||
| def advanced_search(): | ||||
|     # Build custom columns names | ||||
|     cc = get_cc_columns() | ||||
|     calibre_db.session.connection().connection.connection.create_function("lower", 1, calibre_db.lcase) | ||||
|     calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase) | ||||
|     q = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()).order_by(db.Books.sort) | ||||
|  | ||||
|     include_tag_inputs = request.args.getlist('include_tag') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 OzzieIsaacs
					OzzieIsaacs