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
366bf973
Commit
366bf973
authored
Oct 09, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #360 and guest accounts
parent
1eb10be2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
15 deletions
+20
-15
layout.html
cps/templates/layout.html
+8
-6
read.html
cps/templates/read.html
+1
-1
shelf.html
cps/templates/shelf.html
+1
-1
ub.py
cps/ub.py
+4
-1
web.py
cps/web.py
+6
-6
No files found.
cps/templates/layout.html
View file @
366bf973
...
...
@@ -34,7 +34,7 @@
</button>
<a
class=
"navbar-brand"
href=
"{{url_for('index')}}"
>
{{instance}}
</a>
</div>
{% if g.user.is_authenticated or g.user.is_anonymous() %}
{% if g.user.is_authenticated
()
or g.user.is_anonymous() %}
<form
class=
"navbar-form navbar-left"
role=
"search"
action=
"{{url_for('search')}}"
method=
"GET"
>
<div
class=
"form-group input-group input-group-sm"
>
<label
for=
"query"
class=
"sr-only"
>
{{_('Search')}}
</label>
...
...
@@ -46,13 +46,13 @@
</form>
{% endif %}
<div
class=
"navbar-collapse collapse"
>
{% if g.user.is_authenticated or g.user.is_anonymous() %}
{% if g.user.is_authenticated
()
or g.user.is_anonymous() %}
<ul
class=
"nav navbar-nav "
>
<li><a
href=
"{{url_for('advanced_search')}}"
><span
class=
"glyphicon glyphicon-search"
></span><span
class=
"hidden-sm"
>
{{_('Advanced Search')}}
</span></a></li>
</ul>
{% endif %}
<ul
class=
"nav navbar-nav navbar-right"
id=
"main-nav"
>
{% if g.user.is_authenticated or g.user.is_anonymous() %}
{% if g.user.is_authenticated
()
or g.user.is_anonymous() %}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
<li>
...
...
@@ -72,8 +72,10 @@
<li><a
id=
"logout"
href=
"{{url_for('logout')}}"
><span
class=
"glyphicon glyphicon-log-out"
></span><span
class=
"hidden-sm"
>
{{_('Logout')}}
</span></a></li>
{% endif %}
{% endif %}
{% if
g.allow_registration and not g.user.is_authenticated
%}
{% if
not g.user.is_authenticated()
%}
<li><a
id=
"login"
href=
"{{url_for('login')}}"
><span
class=
"glyphicon glyphicon-log-in"
></span>
{{_('Login')}}
</a></li>
{% endif %}
{% if g.allow_registration and not g.user.is_authenticated() %}
<li><a
id=
"register"
href=
"{{url_for('register')}}"
><span
class=
"glyphicon glyphicon-user"
></span>
{{_('Register')}}
</a></li>
{% endif %}
</ul>
...
...
@@ -99,7 +101,7 @@
{% endfor %}
<div
class=
"container-fluid"
>
<div
class=
"row-fluid"
>
{% if g.user.is_authenticated or g.user.is_anonymous() %}
{% if g.user.is_authenticated
()
or g.user.is_anonymous() %}
<div
class=
"col-sm-2"
>
<nav
class=
"navigation"
>
<ul
class=
"list-unstyled"
id=
"scnd-nav"
intent
in-standard-append=
"nav.navigation"
in-mobile-after=
"#main-nav"
in-mobile-class=
"nav navbar-nav"
>
...
...
@@ -140,7 +142,7 @@
{% if g.user.filter_language() == 'all' and g.user.show_language() %}
<li
id=
"nav_lang"
><a
href=
"{{url_for('language_overview')}}"
><span
class=
"glyphicon glyphicon-flag"
></span>
{{_('Languages')}}
</a></li>
{%endif%}
{% if g.user.is_authenticated or g.user.is_anonymous() %}
{% if g.user.is_authenticated
()
or g.user.is_anonymous() %}
<li
class=
"nav-head hidden-xs"
>
{{_('Public Shelves')}}
</li>
{% for shelf in g.public_shelfes %}
<li><a
href=
"{{url_for('show_shelf', shelf_id=shelf.id)}}"
><span
class=
"glyphicon glyphicon-list"
></span>
{{shelf.name}}
</a></li>
...
...
cps/templates/read.html
View file @
366bf973
...
...
@@ -84,7 +84,7 @@
bookUrl
:
"{{ url_for('static', filename=bookid) }}/"
,
bookmarkUrl
:
"{{ url_for('bookmark', book_id=bookid, book_format='EPUB') }}"
,
bookmark
:
"{{ bookmark.bookmark_key if bookmark != None }}"
,
useBookmarks
:
{{
g
.
user
.
is_authenticated
|
tojson
}}
useBookmarks
:
{{
g
.
user
.
is_authenticated
()
|
tojson
}}
};
</script>
<script
src=
"{{ url_for('static', filename='js/libs/jquery.min.js') }}"
></script>
...
...
cps/templates/shelf.html
View file @
366bf973
...
...
@@ -2,7 +2,7 @@
{% block body %}
<div
class=
"discover"
>
<h2>
{{title}}
</h2>
{% if g.user.is_authenticated %}
{% if g.user.is_authenticated
()
%}
{% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %}
<div
data-toggle=
"modal"
data-target=
"#DeleteShelfDialog"
class=
"btn btn-danger"
>
{{ _('Delete this Shelf') }}
</div>
<a
href=
"{{ url_for('edit_shelf', shelf_id=shelf.id) }}"
class=
"btn btn-primary"
>
{{ _('Edit Shelf name') }}
</a>
...
...
cps/ub.py
View file @
366bf973
...
...
@@ -51,7 +51,7 @@ DEVELOPMENT = False
class
UserBase
:
@
static
method
@
class
method
def
is_authenticated
(
self
):
return
True
...
...
@@ -172,6 +172,7 @@ class Anonymous(AnonymousUserMixin, UserBase):
settings
=
session
.
query
(
Settings
)
.
first
()
self
.
nickname
=
data
.
nickname
self
.
role
=
data
.
role
self
.
id
=
data
.
id
self
.
sidebar_view
=
data
.
sidebar_view
self
.
default_language
=
data
.
default_language
self
.
locale
=
data
.
locale
...
...
@@ -187,6 +188,8 @@ class Anonymous(AnonymousUserMixin, UserBase):
def
is_anonymous
(
self
):
return
self
.
anon_browse
def
is_authenticated
(
self
):
return
False
# Baseclass representing Shelfs in calibre-web inapp.db
class
Shelf
(
Base
):
...
...
cps/web.py
View file @
366bf973
...
...
@@ -866,7 +866,7 @@ def get_opds_download_link(book_id, book_format):
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
data
=
db
.
session
.
query
(
db
.
Data
)
.
filter
(
db
.
Data
.
book
==
book
.
id
)
.
filter
(
db
.
Data
.
format
==
book_format
.
upper
())
.
first
()
app
.
logger
.
info
(
data
.
name
)
if
current_user
.
is_authenticated
:
if
current_user
.
is_authenticated
()
:
helper
.
update_download
(
book_id
,
int
(
current_user
.
id
))
file_name
=
book
.
title
if
len
(
book
.
authors
)
>
0
:
...
...
@@ -1791,7 +1791,7 @@ def read_book(book_id, book_format):
if
not
os
.
path
.
exists
(
book_dir
):
os
.
mkdir
(
book_dir
)
bookmark
=
None
if
current_user
.
is_authenticated
:
if
current_user
.
is_authenticated
()
:
bookmark
=
ub
.
session
.
query
(
ub
.
Bookmark
)
.
filter
(
ub
.
and_
(
ub
.
Bookmark
.
user_id
==
int
(
current_user
.
id
),
ub
.
Bookmark
.
book_id
==
book_id
,
ub
.
Bookmark
.
format
==
book_format
.
upper
()))
.
first
()
...
...
@@ -1842,7 +1842,7 @@ def get_download_link(book_id, book_format):
data
=
db
.
session
.
query
(
db
.
Data
)
.
filter
(
db
.
Data
.
book
==
book
.
id
)
.
filter
(
db
.
Data
.
format
==
book_format
.
upper
())
.
first
()
if
data
:
# collect downloaded books only for registered user and not for anonymous user
if
current_user
.
is_authenticated
:
if
current_user
.
is_authenticated
()
:
helper
.
update_download
(
book_id
,
int
(
current_user
.
id
))
file_name
=
book
.
title
if
len
(
book
.
authors
)
>
0
:
...
...
@@ -1876,7 +1876,7 @@ def get_download_link_ext(book_id, book_format, anyname):
def
register
():
if
not
config
.
config_public_reg
:
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'
))
if
request
.
method
==
"POST"
:
...
...
@@ -1913,7 +1913,7 @@ def register():
def
login
():
if
not
config
.
db_configured
:
return
redirect
(
url_for
(
'basic_configuration'
))
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'
))
if
request
.
method
==
"POST"
:
form
=
request
.
form
.
to_dict
()
...
...
@@ -1940,7 +1940,7 @@ def login():
@
app
.
route
(
'/logout'
)
@
login_required
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
()
return
redirect
(
url_for
(
'login'
))
...
...
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