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
1fc4bc52
Commit
1fc4bc52
authored
Feb 09, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix routes
Fix error page
parent
f5235b1d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
11 deletions
+10
-11
shelf.py
cps/shelf.py
+6
-6
http_error.html
cps/templates/http_error.html
+1
-1
web.py
cps/web.py
+3
-4
No files found.
cps/shelf.py
View file @
1fc4bc52
...
...
@@ -22,7 +22,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
flask
import
Blueprint
,
request
,
flash
,
redirect
,
url_for
from
cps
import
ub
from
cps
import
ub
,
searched_ids
from
flask_babel
import
gettext
as
_
from
sqlalchemy.sql.expression
import
func
,
or_
from
flask_login
import
login_required
,
current_user
...
...
@@ -104,18 +104,18 @@ def search_to_shelf(shelf_id):
flash
(
_
(
u"User is not allowed to edit public shelves"
),
category
=
"error"
)
return
redirect
(
url_for
(
'index'
))
if
current_user
.
id
in
ub
.
searched_ids
and
ub
.
searched_ids
[
current_user
.
id
]:
if
current_user
.
id
in
searched_ids
and
searched_ids
[
current_user
.
id
]:
books_for_shelf
=
list
()
books_in_shelf
=
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
all
()
if
books_in_shelf
:
book_ids
=
list
()
for
book_id
in
books_in_shelf
:
book_ids
.
append
(
book_id
.
book_id
)
for
id
in
ub
.
searched_ids
[
current_user
.
id
]:
for
id
in
searched_ids
[
current_user
.
id
]:
if
id
not
in
book_ids
:
books_for_shelf
.
append
(
id
)
else
:
books_for_shelf
=
ub
.
searched_ids
[
current_user
.
id
]
books_for_shelf
=
searched_ids
[
current_user
.
id
]
if
not
books_for_shelf
:
app
.
logger
.
info
(
"Books are already part of the shelf:
%
s"
%
shelf
.
name
)
...
...
@@ -136,7 +136,7 @@ def search_to_shelf(shelf_id):
flash
(
_
(
u"Books have been added to shelf:
%(sname)
s"
,
sname
=
shelf
.
name
),
category
=
"success"
)
else
:
flash
(
_
(
u"Could not add books to shelf:
%(sname)
s"
,
sname
=
shelf
.
name
),
category
=
"error"
)
return
redirect
(
url_for
(
'index'
))
return
redirect
(
url_for
(
'
web.
index'
))
@
shelf
.
route
(
"/shelf/remove/<int:shelf_id>/<int:book_id>"
)
...
...
@@ -259,7 +259,7 @@ def delete_shelf(shelf_id):
ub
.
session
.
query
(
ub
.
BookShelf
)
.
filter
(
ub
.
BookShelf
.
shelf
==
shelf_id
)
.
delete
()
ub
.
session
.
commit
()
app
.
logger
.
info
(
_
(
u"successfully deleted shelf
%(name)
s"
,
name
=
cur_shelf
.
name
,
category
=
"success"
))
return
redirect
(
url_for
(
'index'
))
return
redirect
(
url_for
(
'
web.
index'
))
@
shelf
.
route
(
"/shelf/<int:shelf_id>"
)
...
...
cps/templates/http_error.html
View file @
1fc4bc52
...
...
@@ -17,7 +17,7 @@
{% endif %}
</head>
<body>
<div
class=
"
container
text-center"
>
<div
class=
"text-center"
>
<h1>
{{ error_code }}
</h1>
<h3>
{{ error_name }}
</h3>
<a
href=
"{{url_for('web.index')}}"
title=
"{{ _('Back to home') }}"
>
{{_('Back to home')}}
</a>
...
...
cps/web.py
View file @
1fc4bc52
...
...
@@ -23,7 +23,7 @@
from
cps
import
mimetypes
,
global_WorkerThread
,
searched_ids
from
flask
import
render_template
,
request
,
redirect
,
url_for
,
send_from_directory
,
make_response
,
g
,
flash
,
abort
#
from werkzeug.exceptions import default_exceptions
from
werkzeug.exceptions
import
default_exceptions
import
helper
import
os
# from sqlalchemy.sql.expression import func
...
...
@@ -101,7 +101,7 @@ EXTENSIONS_AUDIO = {'mp3', 'm4a', 'm4b'}
# EXTENSIONS_READER = set(['txt', 'pdf', 'epub', 'zip', 'cbz', 'tar', 'cbt'] + (['rar','cbr'] if rar_support else []))
''''
# custom error page
# custom error page
def
error_http
(
error
):
return
render_template
(
'http_error.html'
,
error_code
=
error
.
code
,
...
...
@@ -115,7 +115,7 @@ for ex in default_exceptions:
if
ex
<
500
:
app
.
register_error_handler
(
ex
,
error_http
)
'''
web
=
Blueprint
(
'web'
,
__name__
)
...
...
@@ -967,7 +967,6 @@ def advanced_search():
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
"lower"
,
1
,
db
.
lcase
)
q
=
db
.
session
.
query
(
db
.
Books
)
# postargs = request.form.to_dict()
include_tag_inputs
=
request
.
args
.
getlist
(
'include_tag'
)
exclude_tag_inputs
=
request
.
args
.
getlist
(
'exclude_tag'
)
...
...
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