Migration of view settings working in User database

Book Merge gives now feedback on what is done
This commit is contained in:
OzzieIsaacs 2020-08-22 10:27:09 +02:00
parent ad144922fb
commit f2add3f788
5 changed files with 50 additions and 10 deletions

View File

@ -987,12 +987,26 @@ def get_sorted_entry(field, bookid):
return ""
@editbook.route("/ajax/simulatemerge", methods=['POST'])
@login_required
def simulate_merge_list_book():
vals = request.get_json().get('Merge_books')
if vals:
to_book = calibre_db.get_book(vals[0]).title
vals.pop(0)
if to_book:
for book_id in vals:
from_book = []
from_book.append(calibre_db.get_book(book_id).title)
return json.dumps({'to': to_book, 'from': from_book})
return ""
@editbook.route("/ajax/mergebooks", methods=['POST'])
@login_required
def merge_list_book():
vals = request.get_json().get('Merge_books')
to_file= list()
to_file = list()
if vals:
# load all formats from target book
to_book = calibre_db.get_book(vals[0])
@ -1020,4 +1034,5 @@ def merge_list_book():
element.uncompressed_size,
to_name))
delete_book(from_book.id,"", True) # json_resp =
return json.dumps({'success': True})
return ""

View File

@ -1,5 +1,5 @@
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
* Copyright (C) 2018 OzzieIsaacs
* Copyright (C) 2020 OzzieIsaacs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -63,7 +63,25 @@ $(function() {
url: window.location.pathname + "/../../ajax/mergebooks",
data: JSON.stringify({"Merge_books":selections}),
success: function success() {
// ToDo:
$('#books-table').bootstrapTable('refresh');
$("#books-table").bootstrapTable('uncheckAll');
}
});
});
$("#merge_books").click(function() {
$.ajax({
method:"post",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: window.location.pathname + "/../../ajax/simulatemerge",
data: JSON.stringify({"Merge_books":selections}),
success: function success(book_titles) {
$.each(book_titles.from, function(i, item) {
$("<span>- " + item + "</span>").appendTo("#merge_from");
});
$('#merge_to').text("- " + book_titles.to);
}
});
});

View File

@ -69,10 +69,15 @@
<div class="modal-header bg-danger text-center">
<span>{{_('Are you really sure?')}}</span>
</div>
<div class="modal-body text-center">
<p>
<span id="">{{_('This books will merged together with the first selected book')}}</span>
</p>
<div class="modal-body">
<p></p>
<div class="text-left">{{_('Books with Title will be merged from:')}}</div>
<p></p>
<div class=text-left" id="merge_from"></div>
<p></p>
<div class="text-left">{{_('Into Book with Title:')}}</div>
<p></p>
<div class=text-left" id="merge_to"></div>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-danger" value="{{_('Merge')}}" name="merge_confirm" id="merge_confirm" data-dismiss="modal">

View File

@ -574,7 +574,8 @@ def migrate_Database(session):
session.query(exists().where(User.view_settings)).scalar()
except exc.OperationalError:
with engine.connect() as conn:
conn.execute("ALTER TABLE user ADD column `series_view` VARCHAR(10) DEFAULT 'list'")
conn.execute("ALTER TABLE user ADD column `view_settings` VARCHAR(10) DEFAULT '{}'")
session.commit()
if session.query(User).filter(User.role.op('&')(constants.ROLE_ANONYMOUS) == constants.ROLE_ANONYMOUS).first() \
is None:
@ -600,7 +601,7 @@ def migrate_Database(session):
"UNIQUE (nickname),"
"UNIQUE (email))")
conn.execute("INSERT INTO user_id(id, nickname, email, role, password, kindle_mail,locale,"
"sidebar_view, default_language, series_view) "
"sidebar_view, default_language, view_settings) "
"SELECT id, nickname, email, role, password, kindle_mail, locale,"
"sidebar_view, default_language FROM user")
# delete old user table and rename new user_id table to user:

View File

@ -1645,10 +1645,11 @@ def profile():
languages = calibre_db.speaking_language()
translations = babel.list_translations() + [LC('en')]
kobo_support = feature_support['kobo'] and config.config_kobo_sync
if feature_support['oauth']:
if feature_support['oauth'] and config.config_login_type == 2:
oauth_status = get_oauth_status()
else:
oauth_status = None
oauth_check = {}
for book in current_user.downloads:
downloadBook = calibre_db.get_book(book.book_id)