mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-31 07:13:02 +00:00 
			
		
		
		
	Bugfix for non existent rating, language, and user downloaded books
This commit is contained in:
		
							
								
								
									
										15
									
								
								cps/web.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								cps/web.py
									
									
									
									
									
								
							| @@ -484,7 +484,8 @@ def render_downloaded_books(page, order, user_id): | |||||||
|         user_id = int(user_id) |         user_id = int(user_id) | ||||||
|     else: |     else: | ||||||
|         user_id = current_user.id |         user_id = current_user.id | ||||||
|     if current_user.check_visibility(constants.SIDEBAR_DOWNLOAD): |     user = ub.session.query(ub.User).filter(ub.User.id == user_id).first() | ||||||
|  |     if current_user.check_visibility(constants.SIDEBAR_DOWNLOAD) and user: | ||||||
|         entries, random, pagination = calibre_db.fill_indexpage(page, |         entries, random, pagination = calibre_db.fill_indexpage(page, | ||||||
|                                                             0, |                                                             0, | ||||||
|                                                             db.Books, |                                                             db.Books, | ||||||
| @@ -499,7 +500,6 @@ def render_downloaded_books(page, order, user_id): | |||||||
|             if not (calibre_db.session.query(db.Books).filter(calibre_db.common_filters()) |             if not (calibre_db.session.query(db.Books).filter(calibre_db.common_filters()) | ||||||
|                     .filter(db.Books.id == book.Books.id).first()): |                     .filter(db.Books.id == book.Books.id).first()): | ||||||
|                 ub.delete_download(book.Books.id) |                 ub.delete_download(book.Books.id) | ||||||
|         user = ub.session.query(ub.User).filter(ub.User.id == user_id).first() |  | ||||||
|         return render_title_template('index.html', |         return render_title_template('index.html', | ||||||
|                                      random=random, |                                      random=random, | ||||||
|                                      entries=entries, |                                      entries=entries, | ||||||
| @@ -618,21 +618,19 @@ def render_ratings_books(page, book_id, order): | |||||||
|                                                                 db.Series, |                                                                 db.Series, | ||||||
|                                                                 db.books_ratings_link, db.Ratings) |                                                                 db.books_ratings_link, db.Ratings) | ||||||
|         title = _("Rating: None") |         title = _("Rating: None") | ||||||
|         rating = -1 |  | ||||||
|     else: |     else: | ||||||
|         name = calibre_db.session.query(db.Ratings).filter(db.Ratings.id == book_id).first() |         name = calibre_db.session.query(db.Ratings).filter(db.Ratings.id == book_id).first() | ||||||
|  |         if name: | ||||||
|             entries, random, pagination = calibre_db.fill_indexpage(page, 0, |             entries, random, pagination = calibre_db.fill_indexpage(page, 0, | ||||||
|                                                                     db.Books, |                                                                     db.Books, | ||||||
|                                                                     db.Books.ratings.any(db.Ratings.id == book_id), |                                                                     db.Books.ratings.any(db.Ratings.id == book_id), | ||||||
|                                                                     [order[0][0]], |                                                                     [order[0][0]], | ||||||
|                                                                     True, config.config_read_column) |                                                                     True, config.config_read_column) | ||||||
|             title = _("Rating: %(rating)s stars", rating=int(name.rating / 2)) |             title = _("Rating: %(rating)s stars", rating=int(name.rating / 2)) | ||||||
|         rating = name.rating |  | ||||||
|     if title and rating <= 10: |  | ||||||
|         return render_title_template('index.html', random=random, pagination=pagination, entries=entries, id=book_id, |  | ||||||
|                                      title=title, page="ratings", order=order[1]) |  | ||||||
|         else: |         else: | ||||||
|             abort(404) |             abort(404) | ||||||
|  |     return render_title_template('index.html', random=random, pagination=pagination, entries=entries, id=book_id, | ||||||
|  |                                  title=title, page="ratings", order=order[1]) | ||||||
|  |  | ||||||
|  |  | ||||||
| def render_formats_books(page, book_id, order): | def render_formats_books(page, book_id, order): | ||||||
| @@ -688,6 +686,8 @@ def render_language_books(page, name, order): | |||||||
|     try: |     try: | ||||||
|         if name.lower() != "none": |         if name.lower() != "none": | ||||||
|             lang_name = isoLanguages.get_language_name(get_locale(), name) |             lang_name = isoLanguages.get_language_name(get_locale(), name) | ||||||
|  |             if lang_name == "Unknown": | ||||||
|  |                 abort(404) | ||||||
|         else: |         else: | ||||||
|             lang_name = _("None") |             lang_name = _("None") | ||||||
|     except KeyError: |     except KeyError: | ||||||
| @@ -1036,6 +1036,7 @@ def ratings_list(): | |||||||
|                            .filter(or_(db.Ratings.rating == None, db.Ratings.rating == 0)) |                            .filter(or_(db.Ratings.rating == None, db.Ratings.rating == 0)) | ||||||
|                            .filter(calibre_db.common_filters()) |                            .filter(calibre_db.common_filters()) | ||||||
|                            .count()) |                            .count()) | ||||||
|  |         if no_rating_count: | ||||||
|             entries.append([db.Category(_("None"), "-1", -1), no_rating_count]) |             entries.append([db.Category(_("None"), "-1", -1), no_rating_count]) | ||||||
|         entries = sorted(entries, key=lambda x: x[0].rating, reverse=not order_no) |         entries = sorted(entries, key=lambda x: x[0].rating, reverse=not order_no) | ||||||
|         return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=list(), |         return render_title_template('list.html', entries=entries, folder='web.books_list', charlist=list(), | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ozzie Isaacs
					Ozzie Isaacs