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
fadd085b
Commit
fadd085b
authored
Oct 26, 2019
by
Jan Guzej
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checking and warrying on possible duplicity
parent
5167ee52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
editbooks.py
cps/editbooks.py
+6
-0
helper.py
cps/helper.py
+10
-0
layout.html
cps/templates/layout.html
+5
-0
No files found.
cps/editbooks.py
View file @
fadd085b
...
@@ -567,6 +567,12 @@ def upload():
...
@@ -567,6 +567,12 @@ def upload():
filepath
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
author_dir
,
title_dir
)
filepath
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
author_dir
,
title_dir
)
saved_filename
=
os
.
path
.
join
(
filepath
,
title_dir
+
meta
.
extension
.
lower
())
saved_filename
=
os
.
path
.
join
(
filepath
,
title_dir
+
meta
.
extension
.
lower
())
if
unicode
(
title
)
!=
u'Unknown'
and
unicode
(
authr
)
!=
u'Unknown'
:
entry
=
helper
.
check_exists_book
(
authr
,
title
)
if
entry
:
book_html
=
flash
(
_
(
u"Uploaded book probably exists in the library, consider to change before upload new: "
)
+
Markup
(
render_title_template
(
'book_exists_flash.html'
,
entry
=
entry
)),
category
=
"warning"
)
# check if file path exists, otherwise create it, copy file to calibre path and delete temp file
# check if file path exists, otherwise create it, copy file to calibre path and delete temp file
if
not
os
.
path
.
exists
(
filepath
):
if
not
os
.
path
.
exists
(
filepath
):
try
:
try
:
...
...
cps/helper.py
View file @
fadd085b
...
@@ -780,7 +780,17 @@ def get_download_link(book_id, book_format):
...
@@ -780,7 +780,17 @@ def get_download_link(book_id, book_format):
else
:
else
:
abort
(
404
)
abort
(
404
)
def
check_exists_book
(
authr
,
title
):
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
"lower"
,
1
,
lcase
)
q
=
list
()
authorterms
=
re
.
split
(
r'\s*&\s*'
,
authr
)
for
authorterm
in
authorterms
:
q
.
append
(
db
.
Books
.
authors
.
any
(
func
.
lower
(
db
.
Authors
.
name
)
.
ilike
(
"
%
"
+
authorterm
+
"
%
"
)))
return
db
.
session
.
query
(
db
.
Books
)
.
filter
(
and_
(
db
.
Books
.
authors
.
any
(
and_
(
*
q
)),
func
.
lower
(
db
.
Books
.
title
)
.
ilike
(
"
%
"
+
title
+
"
%
"
)
))
.
first
()
############### Database Helper functions
############### Database Helper functions
...
...
cps/templates/layout.html
View file @
fadd085b
...
@@ -99,6 +99,11 @@
...
@@ -99,6 +99,11 @@
<div
id=
"flash_info"
class=
"alert alert-info"
>
{{ message[1] }}
</div>
<div
id=
"flash_info"
class=
"alert alert-info"
>
{{ message[1] }}
</div>
</div>
</div>
{%endif%}
{%endif%}
{%if message[0] == "warning" %}
<div
class=
"row-fluid text-center"
style=
"margin-top: -20px;"
>
<div
id=
"flash_warning"
class=
"alert alert-warning"
>
{{ message[1] }}
</div>
</div>
{%endif%}
{%if message[0] == "success" %}
{%if message[0] == "success" %}
<div
class=
"row-fluid text-center"
style=
"margin-top: -20px;"
>
<div
class=
"row-fluid text-center"
style=
"margin-top: -20px;"
>
<div
id=
"flash_success"
class=
"alert alert-success"
>
{{ message[1] }}
</div>
<div
id=
"flash_success"
class=
"alert alert-success"
>
{{ message[1] }}
</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