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
9f1f678b
Commit
9f1f678b
authored
Jan 17, 2017
by
idalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset to last commit url_for without _external
parent
4a2f67bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
web.py
cps/web.py
+18
-18
No files found.
cps/web.py
View file @
9f1f678b
...
@@ -250,7 +250,7 @@ class Pagination(object):
...
@@ -250,7 +250,7 @@ class Pagination(object):
def
url_for_other_page
(
page
):
def
url_for_other_page
(
page
):
args
=
request
.
view_args
.
copy
()
args
=
request
.
view_args
.
copy
()
args
[
'page'
]
=
page
args
[
'page'
]
=
page
return
url_for
(
request
.
endpoint
,
_external
=
True
,
**
args
)
return
url_for
(
request
.
endpoint
,
**
args
)
app
.
jinja_env
.
globals
[
'url_for_other_page'
]
=
url_for_other_page
app
.
jinja_env
.
globals
[
'url_for_other_page'
]
=
url_for_other_page
...
@@ -828,7 +828,7 @@ def series(name, page):
...
@@ -828,7 +828,7 @@ def series(name, page):
title
=
_
(
u"Series:
%(serie)
s"
,
serie
=
name
))
title
=
_
(
u"Series:
%(serie)
s"
,
serie
=
name
))
else
:
else
:
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
return
redirect
(
url_for
(
"index"
,
_external
=
True
))
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/language"
)
@
app
.
route
(
"/language"
)
...
@@ -924,7 +924,7 @@ def show_book(id):
...
@@ -924,7 +924,7 @@ def show_book(id):
return
render_template
(
'detail.html'
,
entry
=
entries
,
cc
=
cc
,
title
=
entries
.
title
,
books_shelfs
=
book_in_shelfs
)
return
render_template
(
'detail.html'
,
entry
=
entries
,
cc
=
cc
,
title
=
entries
.
title
,
books_shelfs
=
book_in_shelfs
)
else
:
else
:
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
return
redirect
(
url_for
(
"index"
,
_external
=
True
))
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/admin"
)
@
app
.
route
(
"/admin"
)
...
@@ -961,7 +961,7 @@ def shutdown():
...
@@ -961,7 +961,7 @@ def shutdown():
# add restart command to queue
# add restart command to queue
global_queue
.
put
(
"something"
)
global_queue
.
put
(
"something"
)
flash
(
_
(
u"Server restarts"
),
category
=
"info"
)
flash
(
_
(
u"Server restarts"
),
category
=
"info"
)
return
redirect
(
url_for
(
"index"
,
_external
=
True
))
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/search"
,
methods
=
[
"GET"
])
@
app
.
route
(
"/search"
,
methods
=
[
"GET"
])
...
@@ -1162,7 +1162,7 @@ def register():
...
@@ -1162,7 +1162,7 @@ def register():
if
not
config
.
PUBLIC_REG
:
if
not
config
.
PUBLIC_REG
:
abort
(
404
)
abort
(
404
)
if
current_user
is
not
None
and
current_user
.
is_authenticated
:
if
current_user
is
not
None
and
current_user
.
is_authenticated
:
return
redirect
(
url_for
(
'index'
,
_external
=
True
))
return
redirect
(
url_for
(
'index'
))
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
to_save
=
request
.
form
.
to_dict
()
to_save
=
request
.
form
.
to_dict
()
...
@@ -1186,7 +1186,7 @@ def register():
...
@@ -1186,7 +1186,7 @@ def register():
flash
(
_
(
u"An unknown error occured. Please try again later."
),
category
=
"error"
)
flash
(
_
(
u"An unknown error occured. Please try again later."
),
category
=
"error"
)
return
render_template
(
'register.html'
,
title
=
"register"
)
return
render_template
(
'register.html'
,
title
=
"register"
)
flash
(
"Your account has been created. Please login."
,
category
=
"success"
)
flash
(
"Your account has been created. Please login."
,
category
=
"success"
)
return
redirect
(
url_for
(
'login'
,
_external
=
True
))
return
redirect
(
url_for
(
'login'
))
else
:
else
:
flash
(
_
(
u"This username or email address is already in use."
),
category
=
"error"
)
flash
(
_
(
u"This username or email address is already in use."
),
category
=
"error"
)
return
render_template
(
'register.html'
,
title
=
"register"
)
return
render_template
(
'register.html'
,
title
=
"register"
)
...
@@ -1199,7 +1199,7 @@ def login():
...
@@ -1199,7 +1199,7 @@ def login():
error
=
None
error
=
None
if
current_user
is
not
None
and
current_user
.
is_authenticated
:
if
current_user
is
not
None
and
current_user
.
is_authenticated
:
return
redirect
(
url_for
(
'index'
,
_external
=
True
))
return
redirect
(
url_for
(
'index'
))
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
form
=
request
.
form
.
to_dict
()
form
=
request
.
form
.
to_dict
()
...
@@ -1209,7 +1209,7 @@ def login():
...
@@ -1209,7 +1209,7 @@ def login():
login_user
(
user
,
remember
=
True
)
login_user
(
user
,
remember
=
True
)
flash
(
_
(
u"you are now logged in as: '
%(nickname)
s'"
,
nickname
=
user
.
nickname
),
category
=
"success"
)
flash
(
_
(
u"you are now logged in as: '
%(nickname)
s'"
,
nickname
=
user
.
nickname
),
category
=
"success"
)
# test=
# test=
return
redirect
(
url_for
(
"index"
,
_external
=
True
))
return
redirect
(
url_for
(
"index"
))
else
:
else
:
flash
(
_
(
u"Wrong Username or Password"
),
category
=
"error"
)
flash
(
_
(
u"Wrong Username or Password"
),
category
=
"error"
)
...
@@ -1221,7 +1221,7 @@ def login():
...
@@ -1221,7 +1221,7 @@ def login():
def
logout
():
def
logout
():
if
current_user
is
not
None
and
current_user
.
is_authenticated
:
if
current_user
is
not
None
and
current_user
.
is_authenticated
:
logout_user
()
logout_user
()
return
redirect
(
url_for
(
'login'
,
_external
=
True
))
return
redirect
(
url_for
(
'login'
))
@
app
.
route
(
'/send/<int:book_id>'
)
@
app
.
route
(
'/send/<int:book_id>'
)
...
@@ -1250,7 +1250,7 @@ def add_to_shelf(shelf_id, book_id):
...
@@ -1250,7 +1250,7 @@ def add_to_shelf(shelf_id, book_id):
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
id
==
shelf_id
)
.
first
()
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
id
==
shelf_id
)
.
first
()
if
not
shelf
.
is_public
and
not
shelf
.
user_id
==
int
(
current_user
.
id
):
if
not
shelf
.
is_public
and
not
shelf
.
user_id
==
int
(
current_user
.
id
):
flash
(
"Sorry you are not allowed to add a book to the the shelf:
%
s"
%
shelf
.
name
)
flash
(
"Sorry you are not allowed to add a book to the the shelf:
%
s"
%
shelf
.
name
)
return
redirect
(
url_for
(
'index'
,
_external
=
True
))
return
redirect
(
url_for
(
'index'
))
maxO
=
ub
.
session
.
query
(
func
.
max
(
ub
.
BookShelf
.
order
))
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
first
()
maxO
=
ub
.
session
.
query
(
func
.
max
(
ub
.
BookShelf
.
order
))
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
first
()
if
maxO
[
0
]
is
None
:
if
maxO
[
0
]
is
None
:
maxOrder
=
0
maxOrder
=
0
...
@@ -1272,7 +1272,7 @@ def remove_from_shelf(shelf_id, book_id):
...
@@ -1272,7 +1272,7 @@ def remove_from_shelf(shelf_id, book_id):
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
id
==
shelf_id
)
.
first
()
shelf
=
ub
.
session
.
query
(
ub
.
Shelf
)
.
filter
(
ub
.
Shelf
.
id
==
shelf_id
)
.
first
()
if
not
shelf
.
is_public
and
not
shelf
.
user_id
==
int
(
current_user
.
id
):
if
not
shelf
.
is_public
and
not
shelf
.
user_id
==
int
(
current_user
.
id
):
flash
(
"Sorry you are not allowed to remove a book from this shelf:
%
s"
%
shelf
.
name
)
flash
(
"Sorry you are not allowed to remove a book from this shelf:
%
s"
%
shelf
.
name
)
return
redirect
(
url_for
(
'index'
,
_external
=
True
))
return
redirect
(
url_for
(
'index'
))
book_shelf
=
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
,
book_shelf
=
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
,
ub
.
BookShelf
.
book_id
==
book_id
)
.
first
()
ub
.
BookShelf
.
book_id
==
book_id
)
.
first
()
...
@@ -1356,7 +1356,7 @@ def delete_shelf(shelf_id):
...
@@ -1356,7 +1356,7 @@ def delete_shelf(shelf_id):
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
delete
()
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
delete
()
ub
.
session
.
commit
()
ub
.
session
.
commit
()
flash
(
_
(
"successfully deleted shelf
%(name)
s"
,
name
=
cur_shelf
.
name
,
category
=
"success"
))
flash
(
_
(
"successfully deleted shelf
%(name)
s"
,
name
=
cur_shelf
.
name
,
category
=
"success"
))
return
redirect
(
url_for
(
'index'
,
_external
=
True
))
return
redirect
(
url_for
(
'index'
))
@
app
.
route
(
"/shelf/<int:shelf_id>"
)
@
app
.
route
(
"/shelf/<int:shelf_id>"
)
...
@@ -1540,7 +1540,7 @@ def new_user():
...
@@ -1540,7 +1540,7 @@ def new_user():
ub
.
session
.
add
(
content
)
ub
.
session
.
add
(
content
)
ub
.
session
.
commit
()
ub
.
session
.
commit
()
flash
(
_
(
"User '
%(user)
s' created"
,
user
=
content
.
nickname
),
category
=
"success"
)
flash
(
_
(
"User '
%(user)
s' created"
,
user
=
content
.
nickname
),
category
=
"success"
)
return
redirect
(
url_for
(
'admin'
,
_external
=
True
))
return
redirect
(
url_for
(
'admin'
))
except
IntegrityError
:
except
IntegrityError
:
ub
.
session
.
rollback
()
ub
.
session
.
rollback
()
flash
(
_
(
u"Found an existing account for this email address or nickname."
),
category
=
"error"
)
flash
(
_
(
u"Found an existing account for this email address or nickname."
),
category
=
"error"
)
...
@@ -1605,7 +1605,7 @@ def edit_user(user_id):
...
@@ -1605,7 +1605,7 @@ def edit_user(user_id):
if
"delete"
in
to_save
:
if
"delete"
in
to_save
:
ub
.
session
.
delete
(
content
)
ub
.
session
.
delete
(
content
)
flash
(
_
(
u"User '
%(nick)
s' deleted"
,
nick
=
content
.
nickname
),
category
=
"success"
)
flash
(
_
(
u"User '
%(nick)
s' deleted"
,
nick
=
content
.
nickname
),
category
=
"success"
)
return
redirect
(
url_for
(
'admin'
,
_external
=
True
))
return
redirect
(
url_for
(
'admin'
))
else
:
else
:
if
"password"
in
to_save
and
to_save
[
"password"
]:
if
"password"
in
to_save
and
to_save
[
"password"
]:
content
.
password
=
generate_password_hash
(
to_save
[
"password"
])
content
.
password
=
generate_password_hash
(
to_save
[
"password"
])
...
@@ -1866,14 +1866,14 @@ def edit_book(book_id):
...
@@ -1866,14 +1866,14 @@ def edit_book(book_id):
for
b
in
edited_books_id
:
for
b
in
edited_books_id
:
helper
.
update_dir_stucture
(
b
)
helper
.
update_dir_stucture
(
b
)
if
"detail_view"
in
to_save
:
if
"detail_view"
in
to_save
:
return
redirect
(
url_for
(
'show_book'
,
id
=
book
.
id
,
_external
=
True
))
return
redirect
(
url_for
(
'show_book'
,
id
=
book
.
id
))
else
:
else
:
return
render_template
(
'edit_book.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
)
return
render_template
(
'edit_book.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
)
else
:
else
:
return
render_template
(
'edit_book.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
)
return
render_template
(
'edit_book.html'
,
book
=
book
,
authors
=
author_names
,
cc
=
cc
)
else
:
else
:
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible:"
),
category
=
"error"
)
return
redirect
(
url_for
(
"index"
,
_external
=
True
))
return
redirect
(
url_for
(
"index"
))
@
app
.
route
(
"/upload"
,
methods
=
[
"GET"
,
"POST"
])
@
app
.
route
(
"/upload"
,
methods
=
[
"GET"
,
"POST"
])
...
@@ -1903,12 +1903,12 @@ def upload():
...
@@ -1903,12 +1903,12 @@ def upload():
os
.
makedirs
(
filepath
)
os
.
makedirs
(
filepath
)
except
OSError
:
except
OSError
:
flash
(
_
(
u"Failed to create path
%
s (Permission denied)."
%
filepath
),
category
=
"error"
)
flash
(
_
(
u"Failed to create path
%
s (Permission denied)."
%
filepath
),
category
=
"error"
)
return
redirect
(
url_for
(
'index'
,
_external
=
True
))
return
redirect
(
url_for
(
'index'
))
try
:
try
:
copyfile
(
meta
.
file_path
,
saved_filename
)
copyfile
(
meta
.
file_path
,
saved_filename
)
except
OSError
,
e
:
except
OSError
,
e
:
flash
(
_
(
u"Failed to store file
%
s (Permission denied)."
%
saved_filename
),
category
=
"error"
)
flash
(
_
(
u"Failed to store file
%
s (Permission denied)."
%
saved_filename
),
category
=
"error"
)
return
redirect
(
url_for
(
'index'
,
_external
=
True
))
return
redirect
(
url_for
(
'index'
))
try
:
try
:
os
.
unlink
(
meta
.
file_path
)
os
.
unlink
(
meta
.
file_path
)
except
OSError
,
e
:
except
OSError
,
e
:
...
...
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