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
cf7196ae
Commit
cf7196ae
authored
Jul 09, 2017
by
Jonathan Rehm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to remove nested if-statements
parent
cb5f196f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
web.py
cps/web.py
+13
-8
No files found.
cps/web.py
View file @
cf7196ae
...
@@ -2689,7 +2689,12 @@ def edit_book(book_id):
...
@@ -2689,7 +2689,12 @@ def edit_book(book_id):
lang_filter
=
True
lang_filter
=
True
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
filter
(
lang_filter
)
.
first
()
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
filter
(
lang_filter
)
.
first
()
author_names
=
[]
author_names
=
[]
if
book
:
# Book not found
if
not
book
:
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible"
),
category
=
"error"
)
return
redirect
(
url_for
(
"index"
))
for
index
in
range
(
0
,
len
(
book
.
languages
)):
for
index
in
range
(
0
,
len
(
book
.
languages
)):
try
:
try
:
book
.
languages
[
index
]
.
language_name
=
LC
.
parse
(
book
.
languages
[
index
]
.
lang_code
)
.
get_language_name
(
book
.
languages
[
index
]
.
language_name
=
LC
.
parse
(
book
.
languages
[
index
]
.
lang_code
)
.
get_language_name
(
...
@@ -2698,7 +2703,13 @@ def edit_book(book_id):
...
@@ -2698,7 +2703,13 @@ def edit_book(book_id):
book
.
languages
[
index
]
.
language_name
=
_
(
isoLanguages
.
get
(
part3
=
book
.
languages
[
index
]
.
lang_code
)
.
name
)
book
.
languages
[
index
]
.
language_name
=
_
(
isoLanguages
.
get
(
part3
=
book
.
languages
[
index
]
.
lang_code
)
.
name
)
for
author
in
book
.
authors
:
for
author
in
book
.
authors
:
author_names
.
append
(
author
.
name
)
author_names
.
append
(
author
.
name
)
if
request
.
method
==
'POST'
:
# Show form
if
request
.
method
!=
'POST'
:
return
render_title_template
(
'book_edit.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
,
title
=
_
(
u"edit metadata"
))
# Update book
edited_books_id
=
set
()
edited_books_id
=
set
()
to_save
=
request
.
form
.
to_dict
()
to_save
=
request
.
form
.
to_dict
()
if
book
.
title
!=
to_save
[
"book_title"
]:
if
book
.
title
!=
to_save
[
"book_title"
]:
...
@@ -2872,12 +2883,6 @@ def edit_book(book_id):
...
@@ -2872,12 +2883,6 @@ def edit_book(book_id):
else
:
else
:
return
render_title_template
(
'book_edit.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
,
return
render_title_template
(
'book_edit.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
,
title
=
_
(
u"edit metadata"
))
title
=
_
(
u"edit metadata"
))
else
:
return
render_title_template
(
'book_edit.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
,
title
=
_
(
u"edit metadata"
))
else
:
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible"
),
category
=
"error"
)
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/upload"
,
methods
=
[
"GET"
,
"POST"
])
@
app
.
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