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
1e351eb0
Commit
1e351eb0
authored
Dec 27, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search for read status
parent
1a83bddf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
search_form.html
cps/templates/search_form.html
+8
-0
web.py
cps/web.py
+23
-2
No files found.
cps/templates/search_form.html
View file @
1e351eb0
...
...
@@ -31,6 +31,14 @@
</div>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"read_status"
>
{{_('Read Status')}}
</label>
<select
name=
"read_status"
id=
"read_status"
class=
"form-control"
>
<option
value=
""
selected
></option>
<option
value=
"True"
>
{{_('Yes')}}
</option>
<option
value=
"False"
>
{{_('No')}}
</option>
</select>
</div>
<label
for=
"include_tag"
>
{{_('Tags')}}
</label>
<div
class=
"form-group"
id=
"tag"
>
<div
class=
"btn-toolbar btn-toolbar-lg"
data-toggle=
"buttons"
>
...
...
cps/web.py
View file @
1e351eb0
...
...
@@ -618,7 +618,8 @@ def render_read_books(page, are_read, as_xml=False, order=None):
db_filter
=
and_
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
),
ub
.
ReadBook
.
read_status
==
ub
.
ReadBook
.
STATUS_FINISHED
)
else
:
db_filter
=
coalesce
(
ub
.
ReadBook
.
read_status
,
0
)
!=
ub
.
ReadBook
.
STATUS_FINISHED
db_filter
=
and_
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
),
coalesce
(
ub
.
ReadBook
.
read_status
,
0
)
!=
ub
.
ReadBook
.
STATUS_FINISHED
)
entries
,
random
,
pagination
=
calibre_db
.
fill_indexpage
(
page
,
0
,
db
.
Books
,
db_filter
,
...
...
@@ -1030,6 +1031,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
rating_low
=
term
.
get
(
"ratinghigh"
)
rating_high
=
term
.
get
(
"ratinglow"
)
description
=
term
.
get
(
"comment"
)
read_status
=
term
.
get
(
"read_status"
)
if
author_name
:
author_name
=
author_name
.
strip
()
.
lower
()
.
replace
(
','
,
'|'
)
if
book_title
:
...
...
@@ -1047,7 +1049,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
if
include_tag_inputs
or
exclude_tag_inputs
or
include_series_inputs
or
exclude_series_inputs
or
\
include_languages_inputs
or
exclude_languages_inputs
or
author_name
or
book_title
or
\
publisher
or
pub_start
or
pub_end
or
rating_low
or
rating_high
or
description
or
cc_present
or
\
include_extension_inputs
or
exclude_extension_inputs
:
include_extension_inputs
or
exclude_extension_inputs
or
read_status
:
searchterm
.
extend
((
author_name
.
replace
(
'|'
,
','
),
book_title
,
publisher
))
if
pub_start
:
try
:
...
...
@@ -1076,6 +1078,8 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
searchterm
.
extend
([
_
(
u"Rating <=
%(rating)
s"
,
rating
=
rating_high
)])
if
rating_low
:
searchterm
.
extend
([
_
(
u"Rating >=
%(rating)
s"
,
rating
=
rating_low
)])
if
read_status
:
searchterm
.
extend
([
_
(
u"Read Status =
%(status)
s"
,
status
=
read_status
)])
searchterm
.
extend
(
ext
for
ext
in
include_extension_inputs
)
searchterm
.
extend
(
ext
for
ext
in
exclude_extension_inputs
)
# handle custom columns
...
...
@@ -1092,6 +1096,23 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
q
=
q
.
filter
(
db
.
Books
.
pubdate
>=
pub_start
)
if
pub_end
:
q
=
q
.
filter
(
db
.
Books
.
pubdate
<=
pub_end
)
if
read_status
:
if
config
.
config_read_column
:
if
read_status
==
"True"
:
q
=
q
.
join
(
db
.
cc_classes
[
config
.
config_read_column
],
isouter
=
True
)
\
.
filter
(
db
.
cc_classes
[
config
.
config_read_column
]
.
value
==
True
)
else
:
q
=
q
.
join
(
db
.
cc_classes
[
config
.
config_read_column
],
isouter
=
True
)
\
.
filter
(
coalesce
(
db
.
cc_classes
[
config
.
config_read_column
]
.
value
,
False
)
!=
True
)
else
:
if
read_status
==
"True"
:
q
=
q
.
join
(
ub
.
ReadBook
,
db
.
Books
.
id
==
ub
.
ReadBook
.
book_id
,
isouter
=
True
)
\
.
filter
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
),
ub
.
ReadBook
.
read_status
==
ub
.
ReadBook
.
STATUS_FINISHED
)
else
:
q
=
q
.
join
(
ub
.
ReadBook
,
db
.
Books
.
id
==
ub
.
ReadBook
.
book_id
,
isouter
=
True
)
\
.
filter
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
),
coalesce
(
ub
.
ReadBook
.
read_status
,
0
)
!=
ub
.
ReadBook
.
STATUS_FINISHED
)
if
publisher
:
q
=
q
.
filter
(
db
.
Books
.
publishers
.
any
(
func
.
lower
(
db
.
Publishers
.
name
)
.
ilike
(
"
%
"
+
publisher
+
"
%
"
)))
for
tag
in
include_tag_inputs
:
...
...
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