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
a395e9f3
Commit
a395e9f3
authored
9 years ago
by
Cervinko Cera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove orphaned authors
parent
c6500b7e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
web.py
cps/web.py
+5
-0
No files found.
cps/web.py
View file @
a395e9f3
...
...
@@ -665,11 +665,16 @@ def edit_book(book_id):
to_save
=
request
.
form
.
to_dict
()
book
.
title
=
to_save
[
"book_title"
]
author_id
=
book
.
authors
[
0
]
.
id
is_author
=
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
name
.
like
(
'
%
'
+
to_save
[
"author_name"
]
.
strip
()
+
'
%
'
))
.
first
()
if
book
.
authors
[
0
]
.
name
not
in
(
"Unknown"
,
"Unbekannt"
,
""
,
" "
):
if
is_author
:
book
.
authors
.
append
(
is_author
)
book
.
authors
.
remove
(
db
.
session
.
query
(
db
.
Authors
)
.
get
(
book
.
authors
[
0
]
.
id
))
authors_books_count
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
authors
.
any
(
db
.
Authors
.
id
.
is_
(
author_id
)))
.
count
()
if
authors_books_count
==
0
:
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
id
==
author_id
)
.
delete
()
else
:
book
.
authors
[
0
]
.
name
=
to_save
[
"author_name"
]
.
strip
()
else
:
...
...
This diff is collapsed.
Click to expand it.
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