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
a21a9d65
Commit
a21a9d65
authored
Apr 21, 2016
by
Cervinko Cera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save rating as rating*2 in db and show rating/2 in interface
parent
f57c9c59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
edit_book.html
cps/templates/edit_book.html
+1
-1
web.py
cps/web.py
+18
-6
No files found.
cps/templates/edit_book.html
View file @
a21a9d65
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"rating"
>
Rating
</label>
<label
for=
"rating"
>
Rating
</label>
<input
type=
"
text"
class=
"form-control"
name=
"rating"
id=
"rating"
value=
"{% if book.ratings %}{{book.ratings[0].rating
}}{% endif %}"
>
<input
type=
"
number"
min=
"1"
max=
"5"
step=
"1"
class=
"form-control"
name=
"rating"
id=
"rating"
value=
"{% if book.ratings %}{{book.ratings[0].rating / 2
}}{% endif %}"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"cover_url"
>
Cover URL (jpg)
</label>
<label
for=
"cover_url"
>
Cover URL (jpg)
</label>
...
...
cps/web.py
View file @
a21a9d65
...
@@ -817,13 +817,25 @@ def edit_book(book_id):
...
@@ -817,13 +817,25 @@ def edit_book(book_id):
else
:
else
:
new_series
=
db
.
Series
(
name
=
to_save
[
"series"
]
.
strip
(),
sort
=
to_save
[
"series"
]
.
strip
())
new_series
=
db
.
Series
(
name
=
to_save
[
"series"
]
.
strip
(),
sort
=
to_save
[
"series"
]
.
strip
())
book
.
series
.
append
(
new_series
)
book
.
series
.
append
(
new_series
)
if
to_save
[
"rating"
]
.
strip
():
if
to_save
[
"rating"
]
.
strip
():
is_rating
=
db
.
session
.
query
(
db
.
Ratings
)
.
filter
(
db
.
Ratings
.
rating
==
int
(
to_save
[
"rating"
]
.
strip
()))
.
first
()
old_rating
=
False
if
is_rating
:
if
len
(
book
.
ratings
)
>
0
:
book
.
ratings
[
0
]
=
is_rating
old_rating
=
book
.
ratings
[
0
]
.
rating
else
:
ratingx2
=
int
(
to_save
[
"rating"
])
*
2
new_rating
=
db
.
Ratings
(
rating
=
int
(
to_save
[
"rating"
]
.
strip
()))
if
ratingx2
!=
old_rating
:
book
.
ratings
[
0
]
=
new_rating
is_rating
=
db
.
session
.
query
(
db
.
Ratings
)
.
filter
(
db
.
Ratings
.
rating
==
ratingx2
)
.
first
()
if
is_rating
:
book
.
ratings
.
append
(
is_rating
)
else
:
new_rating
=
db
.
Ratings
(
rating
=
ratingx2
)
book
.
ratings
.
append
(
new_rating
)
if
old_rating
:
book
.
ratings
.
remove
(
book
.
ratings
[
0
])
else
:
if
len
(
book
.
ratings
)
>
0
:
book
.
ratings
.
remove
(
book
.
ratings
[
0
])
for
c
in
cc
:
for
c
in
cc
:
cc_string
=
"custom_column_"
+
str
(
c
.
id
)
cc_string
=
"custom_column_"
+
str
(
c
.
id
)
...
...
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