mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 12:30:00 +00:00
Fix #1170 Auth-digest Header no longer crashs calibre-web
Fix #1161 Shelfs are reordering again Update Sortable.js to 2.10.1 Code cosmetics
This commit is contained in:
parent
f67953c447
commit
b33a2ac90d
17
cps/shelf.py
17
cps/shelf.py
@ -284,8 +284,14 @@ def show_shelf(shelf_type, shelf_id):
|
||||
|
||||
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id)\
|
||||
.order_by(ub.BookShelf.order.asc()).all()
|
||||
books_list = [ b.book_id for b in books_in_shelf]
|
||||
result = db.session.query(db.Books).filter(db.Books.id.in_(books_list)).filter(common_filters()).all()
|
||||
for book in books_in_shelf:
|
||||
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).filter(common_filters()).first()
|
||||
if cur_book:
|
||||
result.append(cur_book)
|
||||
else:
|
||||
log.info('Not existing book %s in %s deleted', book.book_id, shelf)
|
||||
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book.book_id).delete()
|
||||
ub.session.commit()
|
||||
return render_title_template(page, entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name),
|
||||
shelf=shelf, page="shelf")
|
||||
else:
|
||||
@ -317,8 +323,11 @@ def order_shelf(shelf_id):
|
||||
if shelf:
|
||||
books_in_shelf2 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id) \
|
||||
.order_by(ub.BookShelf.order.asc()).all()
|
||||
books_list = [ b.book_id for b in books_in_shelf2]
|
||||
result = db.session.query(db.Books).filter(db.Books.id.in_(books_list)).filter(common_filters()).all()
|
||||
for book in books_in_shelf2:
|
||||
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).filter(common_filters()).first()
|
||||
result.append(cur_book)
|
||||
#books_list = [ b.book_id for b in books_in_shelf2]
|
||||
#result = db.session.query(db.Books).filter(db.Books.id.in_(books_list)).filter(common_filters()).all()
|
||||
return render_title_template('shelf_order.html', entries=result,
|
||||
title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name),
|
||||
shelf=shelf, page="shelforder")
|
||||
|
@ -55,9 +55,9 @@ $(function () {
|
||||
$(".cover img").attr("src", book.cover);
|
||||
$("#cover_url").val(book.cover);
|
||||
$("#pubdate").val(book.publishedDate);
|
||||
$("#publisher").val(book.publisher)
|
||||
if (book.series != undefined) {
|
||||
$("#series").val(book.series)
|
||||
$("#publisher").val(book.publisher);
|
||||
if (typeof book.series !== "undefined") {
|
||||
$("#series").val(book.series);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,16 +72,18 @@ $(function () {
|
||||
}
|
||||
function formatDate (date) {
|
||||
var d = new Date(date),
|
||||
month = '' + (d.getMonth() + 1),
|
||||
day = '' + d.getDate(),
|
||||
month = "" + (d.getMonth() + 1),
|
||||
day = "" + d.getDate(),
|
||||
year = d.getFullYear();
|
||||
|
||||
if (month.length < 2)
|
||||
month = '0' + month;
|
||||
if (day.length < 2)
|
||||
day = '0' + day;
|
||||
if (month.length < 2) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (day.length < 2) {
|
||||
day = "0" + day;
|
||||
}
|
||||
|
||||
return [year, month, day].join('-');
|
||||
return [year, month, day].join("-");
|
||||
}
|
||||
|
||||
if (ggDone && ggResults.length > 0) {
|
||||
@ -116,15 +118,16 @@ $(function () {
|
||||
}
|
||||
if (dbDone && dbResults.length > 0) {
|
||||
dbResults.forEach(function(result) {
|
||||
if (result.series){
|
||||
var series_title = result.series.title
|
||||
var seriesTitle = "";
|
||||
if (result.series) {
|
||||
seriesTitle = result.series.title;
|
||||
}
|
||||
var date_fomers = result.pubdate.split("-")
|
||||
var publishedYear = parseInt(date_fomers[0])
|
||||
var publishedMonth = parseInt(date_fomers[1])
|
||||
var publishedDate = new Date(publishedYear, publishedMonth-1, 1)
|
||||
var dateFomers = result.pubdate.split("-");
|
||||
var publishedYear = parseInt(dateFomers[0]);
|
||||
var publishedMonth = parseInt(dateFomers[1]);
|
||||
var publishedDate = new Date(publishedYear, publishedMonth - 1, 1);
|
||||
|
||||
publishedDate = formatDate(publishedDate)
|
||||
publishedDate = formatDate(publishedDate);
|
||||
|
||||
var book = {
|
||||
id: result.id,
|
||||
@ -137,7 +140,7 @@ $(function () {
|
||||
return tag.title.toLowerCase().replace(/,/g, "_");
|
||||
}),
|
||||
rating: result.rating.average || 0,
|
||||
series: series_title || "",
|
||||
series: seriesTitle || "",
|
||||
cover: result.image,
|
||||
url: "https://book.douban.com/subject/" + result.id,
|
||||
source: {
|
||||
@ -183,7 +186,7 @@ $(function () {
|
||||
}
|
||||
|
||||
function dbSearchBook (title) {
|
||||
apikey="0df993c66c0c636e29ecbb5344252a4a"
|
||||
var apikey = "0df993c66c0c636e29ecbb5344252a4a";
|
||||
$.ajax({
|
||||
url: douban + dbSearch + "?apikey=" + apikey + "&q=" + title + "&fields=all&count=10",
|
||||
type: "GET",
|
||||
@ -193,7 +196,7 @@ $(function () {
|
||||
dbResults = data.books;
|
||||
},
|
||||
error: function error() {
|
||||
$("#meta-info").html("<p class=\"text-danger\">" + msg.search_error + "!</p>"+ $("#meta-info")[0].innerHTML)
|
||||
$("#meta-info").html("<p class=\"text-danger\">" + msg.search_error + "!</p>" + $("#meta-info")[0].innerHTML);
|
||||
},
|
||||
complete: function complete() {
|
||||
dbDone = true;
|
||||
|
4
cps/static/js/libs/Sortable.min.js
vendored
4
cps/static/js/libs/Sortable.min.js
vendored
File diff suppressed because one or more lines are too long
@ -29,7 +29,7 @@ function sendData(path) {
|
||||
var maxElements;
|
||||
var tmp = [];
|
||||
|
||||
elements = Sortable.utils.find(sortTrue, "div");
|
||||
elements = $(".list-group-item");
|
||||
maxElements = elements.length;
|
||||
|
||||
var form = document.createElement("form");
|
||||
|
@ -150,7 +150,7 @@ def load_user_from_auth_header(header_val):
|
||||
header_val = base64.b64decode(header_val).decode('utf-8')
|
||||
basic_username = header_val.split(':')[0]
|
||||
basic_password = header_val.split(':')[1]
|
||||
except TypeError:
|
||||
except (TypeError, UnicodeDecodeError):
|
||||
pass
|
||||
user = _fetch_user_by_name(basic_username)
|
||||
if user and check_password_hash(str(user.password), basic_password):
|
||||
|
Loading…
Reference in New Issue
Block a user