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
df295e92
Commit
df295e92
authored
Oct 10, 2020
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/Develop' into Develop
parents
9aa01ee8
2e67bd24
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
18 deletions
+22
-18
__init__.py
cps/__init__.py
+0
-1
db.py
cps/db.py
+6
-2
shelf.py
cps/shelf.py
+4
-4
ub.py
cps/ub.py
+9
-1
web.py
cps/web.py
+3
-10
No files found.
cps/__init__.py
View file @
df295e92
...
@@ -73,7 +73,6 @@ ub.init_db(cli.settingspath)
...
@@ -73,7 +73,6 @@ ub.init_db(cli.settingspath)
# pylint: disable=no-member
# pylint: disable=no-member
config
=
config_sql
.
load_configuration
(
ub
.
session
)
config
=
config_sql
.
load_configuration
(
ub
.
session
)
searched_ids
=
{}
web_server
=
WebServer
()
web_server
=
WebServer
()
babel
=
Babel
()
babel
=
Babel
()
...
...
cps/db.py
View file @
df295e92
...
@@ -543,7 +543,7 @@ class CalibreDB():
...
@@ -543,7 +543,7 @@ class CalibreDB():
bind
=
cls
.
engine
))
bind
=
cls
.
engine
))
for
inst
in
cls
.
instances
:
for
inst
in
cls
.
instances
:
inst
.
initSession
()
inst
.
initSession
()
cls
.
_init
=
True
cls
.
_init
=
True
return
True
return
True
...
@@ -685,7 +685,11 @@ class CalibreDB():
...
@@ -685,7 +685,11 @@ class CalibreDB():
else
:
else
:
offset
=
0
offset
=
0
limit_all
=
result_count
limit_all
=
result_count
return
result
[
offset
:
limit_all
],
result_count
,
pagination
ub
.
store_ids
(
result
)
return
result
[
offset
:
limit_all
],
result_count
,
pagination
,
# Creates for all stored languages a translated speaking name in the array for the UI
# Creates for all stored languages a translated speaking name in the array for the UI
def
speaking_language
(
self
,
languages
=
None
):
def
speaking_language
(
self
,
languages
=
None
):
...
...
cps/shelf.py
View file @
df295e92
...
@@ -29,7 +29,7 @@ from flask_login import login_required, current_user
...
@@ -29,7 +29,7 @@ from flask_login import login_required, current_user
from
sqlalchemy.sql.expression
import
func
from
sqlalchemy.sql.expression
import
func
from
sqlalchemy.exc
import
OperationalError
,
InvalidRequestError
from
sqlalchemy.exc
import
OperationalError
,
InvalidRequestError
from
.
import
logger
,
ub
,
searched_ids
,
calibre_db
from
.
import
logger
,
ub
,
calibre_db
from
.web
import
login_required_if_no_ano
,
render_title_template
from
.web
import
login_required_if_no_ano
,
render_title_template
...
@@ -124,18 +124,18 @@ def search_to_shelf(shelf_id):
...
@@ -124,18 +124,18 @@ def search_to_shelf(shelf_id):
flash
(
_
(
u"You are not allowed to add a book to the the shelf:
%(name)
s"
,
name
=
shelf
.
name
),
category
=
"error"
)
flash
(
_
(
u"You are not allowed to add a book to the the shelf:
%(name)
s"
,
name
=
shelf
.
name
),
category
=
"error"
)
return
redirect
(
url_for
(
'web.index'
))
return
redirect
(
url_for
(
'web.index'
))
if
current_user
.
id
in
searched_ids
and
searched_ids
[
current_user
.
id
]:
if
current_user
.
id
in
ub
.
searched_ids
and
ub
.
searched_ids
[
current_user
.
id
]:
books_for_shelf
=
list
()
books_for_shelf
=
list
()
books_in_shelf
=
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
all
()
books_in_shelf
=
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
all
()
if
books_in_shelf
:
if
books_in_shelf
:
book_ids
=
list
()
book_ids
=
list
()
for
book_id
in
books_in_shelf
:
for
book_id
in
books_in_shelf
:
book_ids
.
append
(
book_id
.
book_id
)
book_ids
.
append
(
book_id
.
book_id
)
for
searchid
in
searched_ids
[
current_user
.
id
]:
for
searchid
in
ub
.
searched_ids
[
current_user
.
id
]:
if
searchid
not
in
book_ids
:
if
searchid
not
in
book_ids
:
books_for_shelf
.
append
(
searchid
)
books_for_shelf
.
append
(
searchid
)
else
:
else
:
books_for_shelf
=
searched_ids
[
current_user
.
id
]
books_for_shelf
=
ub
.
searched_ids
[
current_user
.
id
]
if
not
books_for_shelf
:
if
not
books_for_shelf
:
log
.
error
(
"Books are already part of
%
s"
,
shelf
)
log
.
error
(
"Books are already part of
%
s"
,
shelf
)
...
...
cps/ub.py
View file @
df295e92
...
@@ -28,7 +28,7 @@ from binascii import hexlify
...
@@ -28,7 +28,7 @@ from binascii import hexlify
from
flask
import
g
from
flask
import
g
from
flask_babel
import
gettext
as
_
from
flask_babel
import
gettext
as
_
from
flask_login
import
AnonymousUserMixin
from
flask_login
import
AnonymousUserMixin
,
current_user
from
werkzeug.local
import
LocalProxy
from
werkzeug.local
import
LocalProxy
try
:
try
:
from
flask_dance.consumer.backend.sqla
import
OAuthConsumerMixin
from
flask_dance.consumer.backend.sqla
import
OAuthConsumerMixin
...
@@ -54,6 +54,7 @@ from . import constants
...
@@ -54,6 +54,7 @@ from . import constants
session
=
None
session
=
None
app_DB_path
=
None
app_DB_path
=
None
Base
=
declarative_base
()
Base
=
declarative_base
()
searched_ids
=
{}
def
get_sidebar_config
(
kwargs
=
None
):
def
get_sidebar_config
(
kwargs
=
None
):
...
@@ -123,6 +124,13 @@ def get_sidebar_config(kwargs=None):
...
@@ -123,6 +124,13 @@ def get_sidebar_config(kwargs=None):
return
sidebar
return
sidebar
def
store_ids
(
result
):
ids
=
list
()
for
element
in
result
:
ids
.
append
(
element
.
id
)
searched_ids
[
current_user
.
id
]
=
ids
class
UserBase
:
class
UserBase
:
@
property
@
property
...
...
cps/web.py
View file @
df295e92
...
@@ -54,7 +54,7 @@ from werkzeug.datastructures import Headers
...
@@ -54,7 +54,7 @@ from werkzeug.datastructures import Headers
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
.
import
constants
,
logger
,
isoLanguages
,
services
from
.
import
constants
,
logger
,
isoLanguages
,
services
from
.
import
searched_ids
,
lm
,
babel
,
db
,
ub
,
config
,
get_locale
,
app
from
.
import
lm
,
babel
,
db
,
ub
,
config
,
get_locale
,
app
from
.
import
calibre_db
from
.
import
calibre_db
from
.gdriveutils
import
getFileFromEbooksFolder
,
do_gdrive_download
from
.gdriveutils
import
getFileFromEbooksFolder
,
do_gdrive_download
from
.helper
import
check_valid_domain
,
render_task_status
,
\
from
.helper
import
check_valid_domain
,
render_task_status
,
\
...
@@ -956,10 +956,6 @@ def render_prepare_search_form(cc):
...
@@ -956,10 +956,6 @@ def render_prepare_search_form(cc):
def
render_search_results
(
term
,
offset
=
None
,
order
=
None
,
limit
=
None
):
def
render_search_results
(
term
,
offset
=
None
,
order
=
None
,
limit
=
None
):
entries
,
result_count
,
pagination
=
calibre_db
.
get_search_results
(
term
,
offset
,
order
,
limit
)
entries
,
result_count
,
pagination
=
calibre_db
.
get_search_results
(
term
,
offset
,
order
,
limit
)
ids
=
list
()
for
element
in
entries
:
ids
.
append
(
element
.
id
)
searched_ids
[
current_user
.
id
]
=
ids
return
render_title_template
(
'search.html'
,
return
render_title_template
(
'search.html'
,
searchterm
=
term
,
searchterm
=
term
,
pagination
=
pagination
,
pagination
=
pagination
,
...
@@ -1239,6 +1235,7 @@ def search():
...
@@ -1239,6 +1235,7 @@ def search():
title
=
_
(
u"Search"
),
title
=
_
(
u"Search"
),
page
=
"search"
)
page
=
"search"
)
@
web
.
route
(
"/advanced_search"
,
methods
=
[
'POST'
])
@
web
.
route
(
"/advanced_search"
,
methods
=
[
'POST'
])
@
login_required_if_no_ano
@
login_required_if_no_ano
def
advanced_search
():
def
advanced_search
():
...
@@ -1380,11 +1377,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
...
@@ -1380,11 +1377,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
func
.
lower
(
db
.
cc_classes
[
c
.
id
]
.
value
)
.
ilike
(
"
%
"
+
custom_query
+
"
%
"
)))
func
.
lower
(
db
.
cc_classes
[
c
.
id
]
.
value
)
.
ilike
(
"
%
"
+
custom_query
+
"
%
"
)))
q
=
q
.
order_by
(
*
order
)
.
all
()
q
=
q
.
order_by
(
*
order
)
.
all
()
flask_session
[
'query'
]
=
json
.
dumps
(
term
)
flask_session
[
'query'
]
=
json
.
dumps
(
term
)
# ToDo: Check saved ids mechanism ?
ub
.
store_ids
(
q
)
ids
=
list
()
for
element
in
q
:
ids
.
append
(
element
.
id
)
searched_ids
[
current_user
.
id
]
=
ids
# entries, result_count, pagination = calibre_db.get_search_results(term, offset, order, limit)
# entries, result_count, pagination = calibre_db.get_search_results(term, offset, order, limit)
result_count
=
len
(
q
)
result_count
=
len
(
q
)
if
offset
!=
None
and
limit
!=
None
:
if
offset
!=
None
and
limit
!=
None
:
...
...
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