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
34d32259
Commit
34d32259
authored
Sep 05, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Errorhandling edit identifier
parent
eaed53e2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
editbooks.py
cps/editbooks.py
+12
-7
No files found.
cps/editbooks.py
View file @
34d32259
...
...
@@ -154,8 +154,11 @@ def modify_identifiers(input_identifiers, db_identifiers, db_session):
input_identifiers is a list of read-to-persist Identifiers objects.
db_identifiers is a list of already persisted list of Identifiers objects."""
changed
=
False
input_dict
=
dict
([
(
identifier
.
type
.
lower
(),
identifier
)
for
identifier
in
input_identifiers
])
db_dict
=
dict
([
(
identifier
.
type
.
lower
(),
identifier
)
for
identifier
in
db_identifiers
])
error
=
False
input_dict
=
dict
([(
identifier
.
type
.
lower
(),
identifier
)
for
identifier
in
input_identifiers
])
if
len
(
input_identifiers
)
!=
len
(
input_dict
):
error
=
True
db_dict
=
dict
([(
identifier
.
type
.
lower
(),
identifier
)
for
identifier
in
db_identifiers
])
# delete db identifiers not present in input or modify them with input val
for
identifier_type
,
identifier
in
db_dict
.
items
():
if
identifier_type
not
in
input_dict
.
keys
():
...
...
@@ -170,7 +173,7 @@ def modify_identifiers(input_identifiers, db_identifiers, db_session):
if
identifier_type
not
in
db_dict
.
keys
():
db_session
.
add
(
identifier
)
changed
=
True
return
changed
return
changed
,
error
@
editbook
.
route
(
"/ajax/delete/<int:book_id>"
)
@
login_required
...
...
@@ -654,8 +657,10 @@ def edit_book(book_id):
# Handle identifiers
input_identifiers
=
identifier_list
(
to_save
,
book
)
modif_date
|=
modify_identifiers
(
input_identifiers
,
book
.
identifiers
,
calibre_db
.
session
)
modification
,
warning
=
modify_identifiers
(
input_identifiers
,
book
.
identifiers
,
calibre_db
.
session
)
if
warning
:
flash
(
_
(
"Identifiers are not Case Sensitive, Overwriting Old Identifier"
),
category
=
"warning"
)
modif_date
|=
modification
# Handle book tags
modif_date
|=
edit_book_tags
(
to_save
[
'tags'
],
book
)
...
...
@@ -728,7 +733,7 @@ def identifier_list(to_save, book):
val_key
=
id_val_prefix
+
type_key
[
len
(
id_type_prefix
):]
if
val_key
not
in
to_save
.
keys
():
continue
result
.
append
(
db
.
Identifiers
(
to_save
[
val_key
],
type_value
,
book
.
id
)
)
result
.
append
(
db
.
Identifiers
(
to_save
[
val_key
],
type_value
,
book
.
id
)
)
return
result
@
editbook
.
route
(
"/upload"
,
methods
=
[
"GET"
,
"POST"
])
...
...
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