Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
f2add3f7
Commit
f2add3f7
authored
Aug 22, 2020
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migration of view settings working in User database
Book Merge gives now feedback on what is done
parent
ad144922
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
10 deletions
+50
-10
editbooks.py
cps/editbooks.py
+16
-1
table.js
cps/static/js/table.js
+20
-2
book_table.html
cps/templates/book_table.html
+9
-4
ub.py
cps/ub.py
+3
-2
web.py
cps/web.py
+2
-1
No files found.
cps/editbooks.py
View file @
f2add3f7
...
@@ -987,12 +987,26 @@ def get_sorted_entry(field, bookid):
...
@@ -987,12 +987,26 @@ def get_sorted_entry(field, bookid):
return
""
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'
])
@
editbook
.
route
(
"/ajax/mergebooks"
,
methods
=
[
'POST'
])
@
login_required
@
login_required
def
merge_list_book
():
def
merge_list_book
():
vals
=
request
.
get_json
()
.
get
(
'Merge_books'
)
vals
=
request
.
get_json
()
.
get
(
'Merge_books'
)
to_file
=
list
()
to_file
=
list
()
if
vals
:
if
vals
:
# load all formats from target book
# load all formats from target book
to_book
=
calibre_db
.
get_book
(
vals
[
0
])
to_book
=
calibre_db
.
get_book
(
vals
[
0
])
...
@@ -1020,4 +1034,5 @@ def merge_list_book():
...
@@ -1020,4 +1034,5 @@ def merge_list_book():
element
.
uncompressed_size
,
element
.
uncompressed_size
,
to_name
))
to_name
))
delete_book
(
from_book
.
id
,
""
,
True
)
# json_resp =
delete_book
(
from_book
.
id
,
""
,
True
)
# json_resp =
return
json
.
dumps
({
'success'
:
True
})
return
""
return
""
cps/static/js/table.js
View file @
f2add3f7
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
* Copyright (C) 20
18
OzzieIsaacs
* Copyright (C) 20
20
OzzieIsaacs
*
*
* This program is free software: you can redistribute it and/or modify
* 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
* it under the terms of the GNU General Public License as published by
...
@@ -63,7 +63,25 @@ $(function() {
...
@@ -63,7 +63,25 @@ $(function() {
url
:
window
.
location
.
pathname
+
"/../../ajax/mergebooks"
,
url
:
window
.
location
.
pathname
+
"/../../ajax/mergebooks"
,
data
:
JSON
.
stringify
({
"Merge_books"
:
selections
}),
data
:
JSON
.
stringify
({
"Merge_books"
:
selections
}),
success
:
function
success
()
{
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
);
}
}
});
});
});
});
...
...
cps/templates/book_table.html
View file @
f2add3f7
...
@@ -69,10 +69,15 @@
...
@@ -69,10 +69,15 @@
<div
class=
"modal-header bg-danger text-center"
>
<div
class=
"modal-header bg-danger text-center"
>
<span>
{{_('Are you really sure?')}}
</span>
<span>
{{_('Are you really sure?')}}
</span>
</div>
</div>
<div
class=
"modal-body text-center"
>
<div
class=
"modal-body"
>
<p>
<p></p>
<span
id=
""
>
{{_('This books will merged together with the first selected book')}}
</span>
<div
class=
"text-left"
>
{{_('Books with Title will be merged from:')}}
</div>
</p>
<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>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<input
type=
"button"
class=
"btn btn-danger"
value=
"{{_('Merge')}}"
name=
"merge_confirm"
id=
"merge_confirm"
data-dismiss=
"modal"
>
<input
type=
"button"
class=
"btn btn-danger"
value=
"{{_('Merge')}}"
name=
"merge_confirm"
id=
"merge_confirm"
data-dismiss=
"modal"
>
...
...
cps/ub.py
View file @
f2add3f7
...
@@ -574,7 +574,8 @@ def migrate_Database(session):
...
@@ -574,7 +574,8 @@ def migrate_Database(session):
session
.
query
(
exists
()
.
where
(
User
.
view_settings
))
.
scalar
()
session
.
query
(
exists
()
.
where
(
User
.
view_settings
))
.
scalar
()
except
exc
.
OperationalError
:
except
exc
.
OperationalError
:
with
engine
.
connect
()
as
conn
:
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
()
\
if
session
.
query
(
User
)
.
filter
(
User
.
role
.
op
(
'&'
)(
constants
.
ROLE_ANONYMOUS
)
==
constants
.
ROLE_ANONYMOUS
)
.
first
()
\
is
None
:
is
None
:
...
@@ -600,7 +601,7 @@ def migrate_Database(session):
...
@@ -600,7 +601,7 @@ def migrate_Database(session):
"UNIQUE (nickname),"
"UNIQUE (nickname),"
"UNIQUE (email))"
)
"UNIQUE (email))"
)
conn
.
execute
(
"INSERT INTO user_id(id, nickname, email, role, password, kindle_mail,locale,"
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,"
"SELECT id, nickname, email, role, password, kindle_mail, locale,"
"sidebar_view, default_language FROM user"
)
"sidebar_view, default_language FROM user"
)
# delete old user table and rename new user_id table to user:
# delete old user table and rename new user_id table to user:
...
...
cps/web.py
View file @
f2add3f7
...
@@ -1645,10 +1645,11 @@ def profile():
...
@@ -1645,10 +1645,11 @@ def profile():
languages
=
calibre_db
.
speaking_language
()
languages
=
calibre_db
.
speaking_language
()
translations
=
babel
.
list_translations
()
+
[
LC
(
'en'
)]
translations
=
babel
.
list_translations
()
+
[
LC
(
'en'
)]
kobo_support
=
feature_support
[
'kobo'
]
and
config
.
config_kobo_sync
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
()
oauth_status
=
get_oauth_status
()
else
:
else
:
oauth_status
=
None
oauth_status
=
None
oauth_check
=
{}
for
book
in
current_user
.
downloads
:
for
book
in
current_user
.
downloads
:
downloadBook
=
calibre_db
.
get_book
(
book
.
book_id
)
downloadBook
=
calibre_db
.
get_book
(
book
.
book_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment