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
a79600c8
Commit
a79600c8
authored
May 28, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mass change book title and author (fix #1996)
parent
e8a4c3c6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
8 deletions
+74
-8
editbooks.py
cps/editbooks.py
+48
-4
table.js
cps/static/js/table.js
+19
-0
book_table.html
cps/templates/book_table.html
+7
-4
No files found.
cps/editbooks.py
View file @
a79600c8
...
@@ -1148,11 +1148,15 @@ def edit_list_book(param):
...
@@ -1148,11 +1148,15 @@ def edit_list_book(param):
'newValue'
:
' & '
.
join
([
author
.
replace
(
'|'
,
','
)
for
author
in
input_authors
])}),
'newValue'
:
' & '
.
join
([
author
.
replace
(
'|'
,
','
)
for
author
in
input_authors
])}),
mimetype
=
'application/json'
)
mimetype
=
'application/json'
)
book
.
last_modified
=
datetime
.
utcnow
()
book
.
last_modified
=
datetime
.
utcnow
()
try
:
calibre_db
.
session
.
commit
()
calibre_db
.
session
.
commit
()
# revert change for sort if automatic fields link is deactivated
# revert change for sort if automatic fields link is deactivated
if
param
==
'title'
and
vals
.
get
(
'checkT'
)
==
"false"
:
if
param
==
'title'
and
vals
.
get
(
'checkT'
)
==
"false"
:
book
.
sort
=
sort
book
.
sort
=
sort
calibre_db
.
session
.
commit
()
calibre_db
.
session
.
commit
()
except
(
OperationalError
,
IntegrityError
)
as
e
:
calibre_db
.
session
.
rollback
()
log
.
error
(
"Database error:
%
s"
,
e
)
return
ret
return
ret
...
@@ -1224,3 +1228,43 @@ def merge_list_book():
...
@@ -1224,3 +1228,43 @@ def merge_list_book():
delete_book
(
from_book
.
id
,
""
,
True
)
delete_book
(
from_book
.
id
,
""
,
True
)
return
json
.
dumps
({
'success'
:
True
})
return
json
.
dumps
({
'success'
:
True
})
return
""
return
""
@
editbook
.
route
(
"/ajax/xchange"
,
methods
=
[
'POST'
])
@
login_required
@
edit_required
def
table_xchange_author_title
():
vals
=
request
.
get_json
()
.
get
(
'xchange'
)
if
vals
:
for
val
in
vals
:
modif_date
=
False
book
=
calibre_db
.
get_book
(
val
)
authors
=
book
.
title
entries
=
calibre_db
.
order_authors
(
book
)
author_names
=
[]
for
authr
in
entries
.
authors
:
author_names
.
append
(
authr
.
name
.
replace
(
'|'
,
','
))
title_change
=
handle_title_on_edit
(
book
,
" "
.
join
(
author_names
))
input_authors
,
authorchange
=
handle_author_on_edit
(
book
,
authors
)
if
authorchange
or
title_change
:
edited_books_id
=
book
.
id
modif_date
=
True
if
config
.
config_use_google_drive
:
gdriveutils
.
updateGdriveCalibreFromLocal
()
if
edited_books_id
:
helper
.
update_dir_stucture
(
edited_books_id
,
config
.
config_calibre_dir
,
input_authors
[
0
])
if
modif_date
:
book
.
last_modified
=
datetime
.
utcnow
()
try
:
calibre_db
.
session
.
commit
()
except
(
OperationalError
,
IntegrityError
)
as
e
:
calibre_db
.
session
.
rollback
()
log
.
error
(
"Database error:
%
s"
,
e
)
return
json
.
dumps
({
'success'
:
False
})
if
config
.
config_use_google_drive
:
gdriveutils
.
updateGdriveCalibreFromLocal
()
return
json
.
dumps
({
'success'
:
True
})
return
""
cps/static/js/table.js
View file @
a79600c8
...
@@ -46,9 +46,14 @@ $(function() {
...
@@ -46,9 +46,14 @@ $(function() {
if
(
selections
.
length
<
1
)
{
if
(
selections
.
length
<
1
)
{
$
(
"#delete_selection"
).
addClass
(
"disabled"
);
$
(
"#delete_selection"
).
addClass
(
"disabled"
);
$
(
"#delete_selection"
).
attr
(
"aria-disabled"
,
true
);
$
(
"#delete_selection"
).
attr
(
"aria-disabled"
,
true
);
$
(
"#table_xchange"
).
addClass
(
"disabled"
);
$
(
"#table_xchange"
).
attr
(
"aria-disabled"
,
true
);
}
else
{
}
else
{
$
(
"#delete_selection"
).
removeClass
(
"disabled"
);
$
(
"#delete_selection"
).
removeClass
(
"disabled"
);
$
(
"#delete_selection"
).
attr
(
"aria-disabled"
,
false
);
$
(
"#delete_selection"
).
attr
(
"aria-disabled"
,
false
);
$
(
"#table_xchange"
).
removeClass
(
"disabled"
);
$
(
"#table_xchange"
).
attr
(
"aria-disabled"
,
false
);
}
}
});
});
$
(
"#delete_selection"
).
click
(
function
()
{
$
(
"#delete_selection"
).
click
(
function
()
{
...
@@ -86,6 +91,20 @@ $(function() {
...
@@ -86,6 +91,20 @@ $(function() {
});
});
});
});
$
(
"#table_xchange"
).
click
(
function
()
{
$
.
ajax
({
method
:
"post"
,
contentType
:
"application/json; charset=utf-8"
,
dataType
:
"json"
,
url
:
window
.
location
.
pathname
+
"/../../ajax/xchange"
,
data
:
JSON
.
stringify
({
"xchange"
:
selections
}),
success
:
function
success
()
{
$
(
"#books-table"
).
bootstrapTable
(
"refresh"
);
$
(
"#books-table"
).
bootstrapTable
(
"uncheckAll"
);
}
});
});
var
column
=
[];
var
column
=
[];
$
(
"#books-table > thead > tr > th"
).
each
(
function
()
{
$
(
"#books-table > thead > tr > th"
).
each
(
function
()
{
var
element
=
{};
var
element
=
{};
...
...
cps/templates/book_table.html
View file @
a79600c8
...
@@ -20,17 +20,20 @@
...
@@ -20,17 +20,20 @@
{% block body %}
{% block body %}
<h2
class=
"{{page}}"
>
{{_(title)}}
</h2>
<h2
class=
"{{page}}"
>
{{_(title)}}
</h2>
<div
class=
"col-xs-12 col-sm-6"
>
<div
class=
"col-xs-12 col-sm-6"
>
<div
class=
"row"
>
<div
class=
"row
form-group
"
>
<div
class=
"btn btn-default disabled"
id=
"merge_books"
data-toggle=
"modal"
data-target=
"#mergeModal"
aria-disabled=
"true"
>
{{_('Merge selected books')}}
</div>
<div
class=
"btn btn-default disabled"
id=
"merge_books"
data-toggle=
"modal"
data-target=
"#mergeModal"
aria-disabled=
"true"
>
{{_('Merge selected books')}}
</div>
<div
class=
"btn btn-default disabled"
id=
"delete_selection"
aria-disabled=
"true"
>
{{_('Remove Selections')}}
</div>
<div
class=
"btn btn-default disabled"
id=
"delete_selection"
aria-disabled=
"true"
>
{{_('Remove Selections')}}
</div>
</div>
</div>
<div
class=
"row form-group"
>
<div
class=
"btn btn-default disabled"
id=
"table_xchange"
><span
class=
"glyphicon glyphicon-arrow-up"
></span><span
class=
"glyphicon glyphicon-arrow-down"
></span>
{{_('Exchange author and title')}}
</div>
</div>
</div>
<div
class=
"col-xs-12 col-sm-6"
>
</div>
<div
class=
"row"
>
<div
class=
"filterheader col-xs-12 col-sm-6"
>
<div
class=
"row form-group"
>
<input
type=
"checkbox"
id=
"autoupdate_titlesort"
name=
"autoupdate_titlesort"
checked
>
<input
type=
"checkbox"
id=
"autoupdate_titlesort"
name=
"autoupdate_titlesort"
checked
>
<label
for=
"autoupdate_titlesort"
>
{{_('Update Title Sort automatically')}}
</label>
<label
for=
"autoupdate_titlesort"
>
{{_('Update Title Sort automatically')}}
</label>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row
form-group
"
>
<input
type=
"checkbox"
id=
"autoupdate_authorsort"
name=
"autoupdate_authorsort"
checked
>
<input
type=
"checkbox"
id=
"autoupdate_authorsort"
name=
"autoupdate_authorsort"
checked
>
<label
for=
"autoupdate_authorsort"
>
{{_('Update Author Sort automatically')}}
</label>
<label
for=
"autoupdate_authorsort"
>
{{_('Update Author Sort automatically')}}
</label>
</div>
</div>
...
...
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