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
4ae9d4a7
Commit
4ae9d4a7
authored
Apr 14, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into Develop
# Conflicts: # cps/web.py # cps/worker.py
parents
2253708d
55bdd13f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
12 deletions
+21
-12
table.js
cps/static/js/table.js
+3
-2
detail.html
cps/templates/detail.html
+1
-1
ub.py
cps/ub.py
+1
-0
web.py
cps/web.py
+14
-5
worker.py
cps/worker.py
+2
-4
No files found.
cps/static/js/table.js
View file @
4ae9d4a7
...
...
@@ -65,11 +65,12 @@ $(function() {
});
});
/*function TableActions (value, row, index) {
/* Function for deleting domain restrictions */
function
TableActions
(
value
,
row
,
index
)
{
return
[
"<a class=
\"
danger remove
\"
data-toggle=
\"
modal
\"
data-target=
\"
#DeleteDomain
\"
data-domain-id=
\"
"
+
row
.
id
+
"
\"
title=
\"
Remove
\"
>"
,
"<i class=
\"
glyphicon glyphicon-trash
\"
></i>"
,
"</a>"
].
join
(
""
);
}
*/
}
cps/templates/detail.html
View file @
4ae9d4a7
...
...
@@ -40,7 +40,7 @@
</div>
{% endif %}
{% endif %}
{% if g.user.kindle_mail and
g.user.is_authenticated and
kindle_list %}
{% if g.user.kindle_mail and kindle_list %}
{% if kindle_list.__len__() == 1 %}
<a
href=
"{{url_for('web.send_to_kindle', book_id=entry.id, book_format=kindle_list[0]['format'], convert=kindle_list[0]['convert'])}}"
id=
"sendbtn"
data-text=
"{{_('Send to Kindle')}}"
class=
"btn btn-primary"
role=
"button"
><span
class=
"glyphicon glyphicon-send"
></span>
{{kindle_list[0]['text']}}
</a>
{% else %}
...
...
cps/ub.py
View file @
4ae9d4a7
...
...
@@ -272,6 +272,7 @@ class Anonymous(AnonymousUserMixin, UserBase):
self
.
locale
=
data
.
locale
self
.
mature_content
=
data
.
mature_content
self
.
anon_browse
=
settings
.
config_anonbrowse
self
.
kindle_mail
=
data
.
kindle_mail
def
role_admin
(
self
):
return
False
...
...
cps/web.py
View file @
4ae9d4a7
...
...
@@ -52,6 +52,7 @@ import gdriveutils
from
redirect
import
redirect_back
from
cps
import
lm
,
babel
,
ub
,
config
,
get_locale
,
language_table
,
app
,
db
from
pagination
import
Pagination
import
unidecode
feature_support
=
dict
()
...
...
@@ -873,15 +874,20 @@ def advanced_search():
searchterm
=
" + "
.
join
(
filter
(
None
,
searchterm
))
q
=
q
.
filter
()
if
author_name
:
q
=
q
.
filter
(
db
.
Books
.
authors
.
any
(
db
.
Authors
.
name
.
ilike
(
"
%
"
+
author_name
+
"
%
"
)))
q
=
q
.
filter
(
db
.
Books
.
authors
.
any
(
db
.
or_
(
db
.
Authors
.
name
.
ilike
(
"
%
"
+
author_name
+
"
%
"
),
db
.
Authors
.
name
.
ilike
(
"
%
"
+
unidecode
.
unidecode
(
author_name
)
+
"
%
"
))))
if
book_title
:
q
=
q
.
filter
(
db
.
Books
.
title
.
ilike
(
"
%
"
+
book_title
+
"
%
"
))
q
=
q
.
filter
(
db
.
or_
(
db
.
Books
.
title
.
ilike
(
"
%
"
+
book_title
+
"
%
"
),
db
.
Books
.
title
.
ilike
(
"
%
"
+
unidecode
.
unidecode
(
book_title
)
+
"
%
"
)))
if
pub_start
:
q
=
q
.
filter
(
db
.
Books
.
pubdate
>=
pub_start
)
if
pub_end
:
q
=
q
.
filter
(
db
.
Books
.
pubdate
<=
pub_end
)
if
publisher
:
q
=
q
.
filter
(
db
.
Books
.
publishers
.
any
(
db
.
Publishers
.
name
.
ilike
(
"
%
"
+
publisher
+
"
%
"
)))
q
=
q
.
filter
(
db
.
Books
.
publishers
.
any
(
db
.
or_
(
db
.
Publishers
.
name
.
ilike
(
"
%
"
+
publisher
+
"
%
"
),
db
.
Publishers
.
name
.
ilike
(
"
%
"
+
unidecode
.
unidecode
(
publisher
)
+
"
%
"
),)))
for
tag
in
include_tag_inputs
:
q
=
q
.
filter
(
db
.
Books
.
tags
.
any
(
db
.
Tags
.
id
==
tag
))
for
tag
in
exclude_tag_inputs
:
...
...
@@ -904,7 +910,9 @@ def advanced_search():
rating_low
=
int
(
rating_low
)
*
2
q
=
q
.
filter
(
db
.
Books
.
ratings
.
any
(
db
.
Ratings
.
rating
>=
rating_low
))
if
description
:
q
=
q
.
filter
(
db
.
Books
.
comments
.
any
(
db
.
Comments
.
text
.
ilike
(
"
%
"
+
description
+
"
%
"
)))
q
=
q
.
filter
(
db
.
Books
.
comments
.
any
(
db
.
or_
(
db
.
Comments
.
text
.
ilike
(
"
%
"
+
description
+
"
%
"
),
db
.
Comments
.
text
.
ilike
(
"
%
"
+
unidecode
.
unidecode
(
description
)
+
"
%
"
))))
# search custom culumns
for
c
in
cc
:
...
...
@@ -919,7 +927,8 @@ def advanced_search():
db
.
cc_classes
[
c
.
id
]
.
value
==
custom_query
))
else
:
q
=
q
.
filter
(
getattr
(
db
.
Books
,
'custom_column_'
+
str
(
c
.
id
))
.
any
(
db
.
cc_classes
[
c
.
id
]
.
value
.
ilike
(
"
%
"
+
custom_query
+
"
%
"
)))
db
.
or_
(
db
.
cc_classes
[
c
.
id
]
.
value
.
ilike
(
"
%
"
+
custom_query
+
"
%
"
),
db
.
cc_classes
[
c
.
id
]
.
value
.
ilike
(
"
%
"
+
unidecode
.
unidecode
(
custom_query
)
+
"
%
"
))))
q
=
q
.
all
()
ids
=
list
()
for
element
in
q
:
...
...
cps/worker.py
View file @
4ae9d4a7
...
...
@@ -475,9 +475,9 @@ class WorkerThread(threading.Thread):
except
(
MemoryError
)
as
e
:
self
.
_handleError
(
u'Error sending email: '
+
e
.
message
)
return
None
except
(
smtplib
.
SMTPException
)
as
e
:
except
(
smtplib
.
SMTPException
,
smtplib
.
SMTPAuthenticationError
)
as
e
:
if
hasattr
(
e
,
"smtp_error"
):
text
=
e
.
smtp_error
.
replace
(
"
\n
"
,
'. '
)
text
=
e
.
smtp_error
.
decode
(
'utf-8'
)
.
replace
(
"
\n
"
,
'. '
)
elif
hasattr
(
e
,
"message"
):
text
=
e
.
message
else
:
...
...
@@ -502,7 +502,6 @@ class WorkerThread(threading.Thread):
def
_handleError
(
self
,
error_message
):
app
.
logger
.
error
(
error_message
)
# self.queue[self.current]['status'] = STAT_FAIL
self
.
UIqueue
[
self
.
current
][
'stat'
]
=
STAT_FAIL
self
.
UIqueue
[
self
.
current
][
'progress'
]
=
"100
%
"
self
.
UIqueue
[
self
.
current
][
'runtime'
]
=
self
.
_formatRuntime
(
...
...
@@ -510,7 +509,6 @@ class WorkerThread(threading.Thread):
self
.
UIqueue
[
self
.
current
][
'message'
]
=
error_message
def
_handleSuccess
(
self
):
# self.queue[self.current]['status'] = STAT_FINISH_SUCCESS
self
.
UIqueue
[
self
.
current
][
'stat'
]
=
STAT_FINISH_SUCCESS
self
.
UIqueue
[
self
.
current
][
'progress'
]
=
"100
%
"
self
.
UIqueue
[
self
.
current
][
'runtime'
]
=
self
.
_formatRuntime
(
...
...
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