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
80c3c19c
Commit
80c3c19c
authored
May 03, 2016
by
Cervinko Cera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some fixes for advanced search
parent
7fce2879
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
style.css
cps/static/css/style.css
+1
-0
search_form.html
cps/templates/search_form.html
+1
-2
web.py
cps/web.py
+6
-4
No files found.
cps/static/css/style.css
View file @
80c3c19c
...
...
@@ -36,3 +36,4 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
.btn-primary
:hover
,
.btn-primary
:focus
,
.btn-primary
:active
,
.btn-primary.active
,
.open
.dropdown-toggle.btn-primary
{
background-color
:
#1C5484
;
}
.btn-primary.disabled
,
.btn-primary
[
disabled
],
fieldset
[
disabled
]
.btn-primary
,
.btn-primary.disabled
:hover
,
.btn-primary
[
disabled
]
:hover
,
fieldset
[
disabled
]
.btn-primary
:hover
,
.btn-primary.disabled
:focus
,
.btn-primary
[
disabled
]
:focus
,
fieldset
[
disabled
]
.btn-primary
:focus
,
.btn-primary.disabled
:active
,
.btn-primary
[
disabled
]
:active
,
fieldset
[
disabled
]
.btn-primary
:active
,
.btn-primary.disabled.active
,
.btn-primary
[
disabled
]
.active
,
fieldset
[
disabled
]
.btn-primary.active
{
background-color
:
#89B9E2
;
}
.btn-toolbar
>
.btn
+
.btn
,
.btn-toolbar
>
.btn-group
+
.btn
,
.btn-toolbar
>
.btn
+
.btn-group
,
.btn-toolbar
>
.btn-group
+
.btn-group
{
margin-left
:
0px
;
}
cps/templates/search_form.html
View file @
80c3c19c
...
...
@@ -29,11 +29,10 @@
<script
src=
"{{ url_for('static', filename='js/typeahead.bundle.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/edit_books.js') }}"
></script>
<script>
$
(
'form'
).
on
(
'change input'
,
function
()
{
$
(
'form'
).
on
(
'change input
typeahead:selected
'
,
function
()
{
form
=
$
(
'form'
).
serialize
();
$
.
getJSON
(
"{{ url_for('get_matching_tags') }}"
,
form
,
function
(
data
)
{
$
(
'.tag_click'
).
each
(
function
()
{
console
.
log
(
data
.
tags
);
if
(
$
.
inArray
(
parseInt
(
$
(
this
).
children
(
'input'
).
first
().
val
(),
10
),
data
.
tags
)
==
-
1
)
{
$
(
this
).
addClass
(
'disabled'
);
}
...
...
cps/web.py
View file @
80c3c19c
...
...
@@ -451,12 +451,17 @@ def advanced_search():
author_name
=
request
.
args
.
get
(
"author_name"
)
book_title
=
request
.
args
.
get
(
"book_title"
)
if
tag_inputs
or
author_name
or
book_title
:
searchterm
=
[]
searchterm
.
extend
((
author_name
,
book_title
))
tag_names
=
db
.
session
.
query
(
db
.
Tags
)
.
filter
(
db
.
Tags
.
id
.
in_
(
tag_inputs
))
.
all
()
searchterm
.
extend
(
tag
.
name
for
tag
in
tag_names
)
searchterm
=
" + "
.
join
(
filter
(
None
,
searchterm
))
q
=
q
.
filter
(
db
.
Books
.
authors
.
any
(
db
.
Authors
.
name
.
like
(
"
%
"
+
author_name
+
"
%
"
)),
db
.
Books
.
title
.
like
(
"
%
"
+
book_title
+
"
%
"
))
random
=
db
.
session
.
query
(
db
.
Books
)
.
order_by
(
func
.
random
())
.
limit
(
config
.
RANDOM_BOOKS
)
for
tag
in
tag_inputs
:
q
=
q
.
filter
(
db
.
Books
.
tags
.
any
(
db
.
Tags
.
id
==
tag
))
q
=
q
.
all
()
return
render_template
(
'search.html'
,
searchterm
=
"tags"
,
entries
=
q
)
return
render_template
(
'search.html'
,
searchterm
=
searchterm
,
entries
=
q
)
tags
=
db
.
session
.
query
(
db
.
Tags
)
.
order_by
(
db
.
Tags
.
name
)
.
all
()
return
render_template
(
'search_form.html'
,
tags
=
tags
)
...
...
@@ -958,7 +963,6 @@ def edit_book(book_id):
if
len
(
book
.
ratings
)
>
0
:
old_rating
=
book
.
ratings
[
0
]
.
rating
ratingx2
=
int
(
float
(
to_save
[
"rating"
])
*
2
)
print
ratingx2
if
ratingx2
!=
old_rating
:
is_rating
=
db
.
session
.
query
(
db
.
Ratings
)
.
filter
(
db
.
Ratings
.
rating
==
ratingx2
)
.
first
()
if
is_rating
:
...
...
@@ -983,7 +987,6 @@ def edit_book(book_id):
if
to_save
[
cc_string
]
.
strip
():
if
c
.
datatype
==
'rating'
:
to_save
[
cc_string
]
=
str
(
int
(
float
(
to_save
[
cc_string
])
*
2
))
print
to_save
[
cc_string
]
if
to_save
[
cc_string
]
.
strip
()
!=
cc_db_value
:
if
cc_db_value
!=
None
:
#remove old cc_val
...
...
@@ -1046,7 +1049,6 @@ def edit_book(book_id):
new_tag
=
db
.
session
.
query
(
db
.
cc_classes
[
c
.
id
])
.
filter
(
db
.
cc_classes
[
c
.
id
]
.
value
==
add_tag
)
.
first
()
# if no tag is found add it
if
new_tag
==
None
:
print
add_tag
new_tag
=
db
.
cc_classes
[
c
.
id
](
value
=
add_tag
)
db
.
session
.
add
(
new_tag
)
new_tag
=
db
.
session
.
query
(
db
.
cc_classes
[
c
.
id
])
.
filter
(
db
.
cc_classes
[
c
.
id
]
.
value
==
add_tag
)
.
first
()
...
...
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