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
4664b478
Commit
4664b478
authored
Mar 21, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed alphabetical order in list and grid view
Completed download section
parent
9864d932
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
19 deletions
+52
-19
render_template.py
cps/render_template.py
+10
-4
filter_grid.js
cps/static/js/filter_grid.js
+8
-0
filter_list.js
cps/static/js/filter_list.js
+1
-1
grid.html
cps/templates/grid.html
+2
-2
list.html
cps/templates/list.html
+2
-2
web.py
cps/web.py
+29
-10
No files found.
cps/render_template.py
View file @
4664b478
...
@@ -42,10 +42,16 @@ def get_sidebar_config(kwargs=None):
...
@@ -42,10 +42,16 @@ def get_sidebar_config(kwargs=None):
sidebar
.
append
({
"glyph"
:
"glyphicon-fire"
,
"text"
:
_
(
'Hot Books'
),
"link"
:
'web.books_list'
,
"id"
:
"hot"
,
sidebar
.
append
({
"glyph"
:
"glyphicon-fire"
,
"text"
:
_
(
'Hot Books'
),
"link"
:
'web.books_list'
,
"id"
:
"hot"
,
"visibility"
:
constants
.
SIDEBAR_HOT
,
'public'
:
True
,
"page"
:
"hot"
,
"visibility"
:
constants
.
SIDEBAR_HOT
,
'public'
:
True
,
"page"
:
"hot"
,
"show_text"
:
_
(
'Show Hot Books'
),
"config_show"
:
True
})
"show_text"
:
_
(
'Show Hot Books'
),
"config_show"
:
True
})
sidebar
.
append
({
"glyph"
:
"glyphicon-download"
,
"text"
:
_
(
'Downloaded Books'
),
"link"
:
'web.download_list'
,
if
current_user
.
role_admin
():
"id"
:
"download"
,
"visibility"
:
constants
.
SIDEBAR_DOWNLOAD
,
'public'
:
(
not
g
.
user
.
is_anonymous
),
sidebar
.
append
({
"glyph"
:
"glyphicon-download"
,
"text"
:
_
(
'Downloaded Books'
),
"link"
:
'web.download_list'
,
"page"
:
"download"
,
"show_text"
:
_
(
'Show Downloaded Books'
),
"id"
:
"download"
,
"visibility"
:
constants
.
SIDEBAR_DOWNLOAD
,
'public'
:
(
not
g
.
user
.
is_anonymous
),
"config_show"
:
content
})
"page"
:
"download"
,
"show_text"
:
_
(
'Show Downloaded Books'
),
"config_show"
:
content
})
else
:
sidebar
.
append
({
"glyph"
:
"glyphicon-download"
,
"text"
:
_
(
'Downloaded Books'
),
"link"
:
'web.books_list'
,
"id"
:
"download"
,
"visibility"
:
constants
.
SIDEBAR_DOWNLOAD
,
'public'
:
(
not
g
.
user
.
is_anonymous
),
"page"
:
"download"
,
"show_text"
:
_
(
'Show Downloaded Books'
),
"config_show"
:
content
})
sidebar
.
append
(
sidebar
.
append
(
{
"glyph"
:
"glyphicon-star"
,
"text"
:
_
(
'Top Rated Books'
),
"link"
:
'web.books_list'
,
"id"
:
"rated"
,
{
"glyph"
:
"glyphicon-star"
,
"text"
:
_
(
'Top Rated Books'
),
"link"
:
'web.books_list'
,
"id"
:
"rated"
,
"visibility"
:
constants
.
SIDEBAR_BEST_RATED
,
'public'
:
True
,
"page"
:
"rated"
,
"visibility"
:
constants
.
SIDEBAR_BEST_RATED
,
'public'
:
True
,
"page"
:
"rated"
,
...
...
cps/static/js/filter_grid.js
View file @
4664b478
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
var
direction
=
$
(
"#asc"
).
data
(
'order'
);
// 0=Descending order; 1= ascending order
var
$list
=
$
(
"#list"
).
isotope
({
var
$list
=
$
(
"#list"
).
isotope
({
itemSelector
:
".book"
,
itemSelector
:
".book"
,
layoutMode
:
"fitRows"
,
layoutMode
:
"fitRows"
,
...
@@ -24,6 +26,9 @@ var $list = $("#list").isotope({
...
@@ -24,6 +26,9 @@ var $list = $("#list").isotope({
});
});
$
(
"#desc"
).
click
(
function
()
{
$
(
"#desc"
).
click
(
function
()
{
if
(
direction
===
0
)
{
return
;
}
var
page
=
$
(
this
).
data
(
"id"
);
var
page
=
$
(
this
).
data
(
"id"
);
$
.
ajax
({
$
.
ajax
({
method
:
"post"
,
method
:
"post"
,
...
@@ -39,6 +44,9 @@ $("#desc").click(function() {
...
@@ -39,6 +44,9 @@ $("#desc").click(function() {
});
});
$
(
"#asc"
).
click
(
function
()
{
$
(
"#asc"
).
click
(
function
()
{
if
(
direction
===
1
)
{
return
;
}
var
page
=
$
(
this
).
data
(
"id"
);
var
page
=
$
(
this
).
data
(
"id"
);
$
.
ajax
({
$
.
ajax
({
method
:
"post"
,
method
:
"post"
,
...
...
cps/static/js/filter_list.js
View file @
4664b478
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
var
direction
=
0
;
// De
scending order
var
direction
=
$
(
"#asc"
).
data
(
'order'
);
// 0=Descending order; 1= a
scending order
var
sort
=
0
;
// Show sorted entries
var
sort
=
0
;
// Show sorted entries
$
(
"#sort_name"
).
click
(
function
()
{
$
(
"#sort_name"
).
click
(
function
()
{
...
...
cps/templates/grid.html
View file @
4664b478
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
<button
id=
"sort_name"
class=
"btn btn-primary"
><b>
B,A
<->
A B
</b></button>
<button
id=
"sort_name"
class=
"btn btn-primary"
><b>
B,A
<->
A B
</b></button>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
<button
id=
"
de
sc"
data-id=
"series"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></button>
<button
id=
"
a
sc"
data-id=
"series"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></button>
<button
id=
"
asc"
data-id=
"series
"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></button>
<button
id=
"
desc"
data-id=
"series"
data-order=
"{{ order }}
"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></button>
{% if charlist|length %}
{% if charlist|length %}
<button
id=
"all"
class=
"btn btn-primary"
>
{{_('All')}}
</button>
<button
id=
"all"
class=
"btn btn-primary"
>
{{_('All')}}
</button>
{% endif %}
{% endif %}
...
...
cps/templates/list.html
View file @
4664b478
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
<button
id=
"sort_name"
class=
"btn btn-primary"
><b>
B,A
<->
A B
</b></button>
<button
id=
"sort_name"
class=
"btn btn-primary"
><b>
B,A
<->
A B
</b></button>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
<button
id=
"
desc
"
data-id=
"{{ data }}"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></button>
<button
id=
"
asc"
data-order=
"{{ order }}
"
data-id=
"{{ data }}"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet"
></span></button>
<button
id=
"
a
sc"
data-id=
"{{ data }}"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></button>
<button
id=
"
de
sc"
data-id=
"{{ data }}"
class=
"btn btn-primary"
><span
class=
"glyphicon glyphicon-sort-by-alphabet-alt"
></span></button>
{% if charlist|length %}
{% if charlist|length %}
<button
id=
"all"
class=
"btn btn-primary"
>
{{_('All')}}
</button>
<button
id=
"all"
class=
"btn btn-primary"
>
{{_('All')}}
</button>
{% endif %}
{% endif %}
...
...
cps/web.py
View file @
4664b478
...
@@ -463,7 +463,10 @@ def render_hot_books(page):
...
@@ -463,7 +463,10 @@ def render_hot_books(page):
def
render_downloaded_books
(
page
,
order
,
user_id
):
def
render_downloaded_books
(
page
,
order
,
user_id
):
user_id
=
int
(
user_id
)
if
current_user
.
role_admin
():
user_id
=
int
(
user_id
)
else
:
user_id
=
current_user
.
id
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_DOWNLOAD
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_DOWNLOAD
):
if
current_user
.
show_detail_random
():
if
current_user
.
show_detail_random
():
random
=
calibre_db
.
session
.
query
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
random
=
calibre_db
.
session
.
query
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
...
@@ -486,6 +489,7 @@ def render_downloaded_books(page, order, user_id):
...
@@ -486,6 +489,7 @@ def render_downloaded_books(page, order, user_id):
random
=
random
,
random
=
random
,
entries
=
entries
,
entries
=
entries
,
pagination
=
pagination
,
pagination
=
pagination
,
id
=
user_id
,
title
=
_
(
u"Downloaded books by
%(user)
s"
,
user
=
user
.
name
),
title
=
_
(
u"Downloaded books by
%(user)
s"
,
user
=
user
.
name
),
page
=
"download"
)
page
=
"download"
)
else
:
else
:
...
@@ -799,8 +803,10 @@ def author_list():
...
@@ -799,8 +803,10 @@ def author_list():
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_AUTHOR
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_AUTHOR
):
if
current_user
.
get_view_property
(
'author'
,
'dir'
)
==
'desc'
:
if
current_user
.
get_view_property
(
'author'
,
'dir'
)
==
'desc'
:
order
=
db
.
Authors
.
sort
.
desc
()
order
=
db
.
Authors
.
sort
.
desc
()
order_no
=
0
else
:
else
:
order
=
db
.
Authors
.
sort
.
asc
()
order
=
db
.
Authors
.
sort
.
asc
()
order_no
=
1
entries
=
calibre_db
.
session
.
query
(
db
.
Authors
,
func
.
count
(
'books_authors_link.book'
)
.
label
(
'count'
))
\
entries
=
calibre_db
.
session
.
query
(
db
.
Authors
,
func
.
count
(
'books_authors_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_authors_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
books_authors_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
group_by
(
text
(
'books_authors_link.author'
))
.
order_by
(
order
)
.
all
()
.
group_by
(
text
(
'books_authors_link.author'
))
.
order_by
(
order
)
.
all
()
...
@@ -810,7 +816,7 @@ def author_list():
...
@@ -810,7 +816,7 @@ def author_list():
for
entry
in
entries
:
for
entry
in
entries
:
entry
.
Authors
.
name
=
entry
.
Authors
.
name
.
replace
(
'|'
,
','
)
entry
.
Authors
.
name
=
entry
.
Authors
.
name
.
replace
(
'|'
,
','
)
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
title
=
u"Authors"
,
page
=
"authorlist"
,
data
=
'author'
)
title
=
u"Authors"
,
page
=
"authorlist"
,
data
=
'author'
,
order
=
order_no
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -818,9 +824,11 @@ def author_list():
...
@@ -818,9 +824,11 @@ def author_list():
@
login_required_if_no_ano
@
login_required_if_no_ano
def
download_list
():
def
download_list
():
if
current_user
.
get_view_property
(
'download'
,
'dir'
)
==
'desc'
:
if
current_user
.
get_view_property
(
'download'
,
'dir'
)
==
'desc'
:
order
=
ub
.
User
.
name
.
desc
()
# ToDo
order
=
ub
.
User
.
name
.
desc
()
order_no
=
0
else
:
else
:
order
=
ub
.
User
.
name
.
asc
()
# ToDo
order
=
ub
.
User
.
name
.
asc
()
order_no
=
1
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_DOWNLOAD
)
and
current_user
.
role_admin
():
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_DOWNLOAD
)
and
current_user
.
role_admin
():
entries
=
ub
.
session
.
query
(
ub
.
User
,
func
.
count
(
ub
.
Downloads
.
book_id
)
.
label
(
'count'
))
\
entries
=
ub
.
session
.
query
(
ub
.
User
,
func
.
count
(
ub
.
Downloads
.
book_id
)
.
label
(
'count'
))
\
.
join
(
ub
.
Downloads
)
.
group_by
(
ub
.
Downloads
.
user_id
)
.
order_by
(
order
)
.
all
()
.
join
(
ub
.
Downloads
)
.
group_by
(
ub
.
Downloads
.
user_id
)
.
order_by
(
order
)
.
all
()
...
@@ -828,7 +836,7 @@ def download_list():
...
@@ -828,7 +836,7 @@ def download_list():
.
filter
(
ub
.
User
.
role
.
op
(
'&'
)(
constants
.
ROLE_ANONYMOUS
)
!=
constants
.
ROLE_ANONYMOUS
)
\
.
filter
(
ub
.
User
.
role
.
op
(
'&'
)(
constants
.
ROLE_ANONYMOUS
)
!=
constants
.
ROLE_ANONYMOUS
)
\
.
group_by
(
func
.
upper
(
func
.
substr
(
ub
.
User
.
name
,
1
,
1
)))
.
all
()
.
group_by
(
func
.
upper
(
func
.
substr
(
ub
.
User
.
name
,
1
,
1
)))
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
title
=
_
(
u"Downloads"
),
page
=
"downloadlist"
,
data
=
"download"
)
title
=
_
(
u"Downloads"
),
page
=
"downloadlist"
,
data
=
"download"
,
order
=
order_no
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -838,8 +846,10 @@ def download_list():
...
@@ -838,8 +846,10 @@ def download_list():
def
publisher_list
():
def
publisher_list
():
if
current_user
.
get_view_property
(
'publisher'
,
'dir'
)
==
'desc'
:
if
current_user
.
get_view_property
(
'publisher'
,
'dir'
)
==
'desc'
:
order
=
db
.
Publishers
.
name
.
desc
()
order
=
db
.
Publishers
.
name
.
desc
()
order_no
=
0
else
:
else
:
order
=
db
.
Publishers
.
name
.
asc
()
order
=
db
.
Publishers
.
name
.
asc
()
order_no
=
1
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_PUBLISHER
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_PUBLISHER
):
entries
=
calibre_db
.
session
.
query
(
db
.
Publishers
,
func
.
count
(
'books_publishers_link.book'
)
.
label
(
'count'
))
\
entries
=
calibre_db
.
session
.
query
(
db
.
Publishers
,
func
.
count
(
'books_publishers_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_publishers_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
books_publishers_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
...
@@ -848,7 +858,7 @@ def publisher_list():
...
@@ -848,7 +858,7 @@ def publisher_list():
.
join
(
db
.
books_publishers_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
books_publishers_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Publishers
.
name
,
1
,
1
)))
.
all
()
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Publishers
.
name
,
1
,
1
)))
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
title
=
_
(
u"Publishers"
),
page
=
"publisherlist"
,
data
=
"publisher"
)
title
=
_
(
u"Publishers"
),
page
=
"publisherlist"
,
data
=
"publisher"
,
order
=
order_no
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -859,8 +869,10 @@ def series_list():
...
@@ -859,8 +869,10 @@ def series_list():
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_SERIES
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_SERIES
):
if
current_user
.
get_view_property
(
'series'
,
'dir'
)
==
'desc'
:
if
current_user
.
get_view_property
(
'series'
,
'dir'
)
==
'desc'
:
order
=
db
.
Series
.
sort
.
desc
()
order
=
db
.
Series
.
sort
.
desc
()
order_no
=
0
else
:
else
:
order
=
db
.
Series
.
sort
.
asc
()
order
=
db
.
Series
.
sort
.
asc
()
order_no
=
1
if
current_user
.
get_view_property
(
'series'
,
'series_view'
)
==
'list'
:
if
current_user
.
get_view_property
(
'series'
,
'series_view'
)
==
'list'
:
entries
=
calibre_db
.
session
.
query
(
db
.
Series
,
func
.
count
(
'books_series_link.book'
)
.
label
(
'count'
))
\
entries
=
calibre_db
.
session
.
query
(
db
.
Series
,
func
.
count
(
'books_series_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_series_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
books_series_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
...
@@ -879,7 +891,8 @@ def series_list():
...
@@ -879,7 +891,8 @@ def series_list():
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Series
.
sort
,
1
,
1
)))
.
all
()
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Series
.
sort
,
1
,
1
)))
.
all
()
return
render_title_template
(
'grid.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
return
render_title_template
(
'grid.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
title
=
_
(
u"Series"
),
page
=
"serieslist"
,
data
=
"series"
,
bodyClass
=
"grid-view"
)
title
=
_
(
u"Series"
),
page
=
"serieslist"
,
data
=
"series"
,
bodyClass
=
"grid-view"
,
order
=
order_no
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -890,14 +903,16 @@ def ratings_list():
...
@@ -890,14 +903,16 @@ def ratings_list():
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_RATING
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_RATING
):
if
current_user
.
get_view_property
(
'ratings'
,
'dir'
)
==
'desc'
:
if
current_user
.
get_view_property
(
'ratings'
,
'dir'
)
==
'desc'
:
order
=
db
.
Ratings
.
rating
.
desc
()
order
=
db
.
Ratings
.
rating
.
desc
()
order_no
=
0
else
:
else
:
order
=
db
.
Ratings
.
rating
.
asc
()
order
=
db
.
Ratings
.
rating
.
asc
()
order_no
=
1
entries
=
calibre_db
.
session
.
query
(
db
.
Ratings
,
func
.
count
(
'books_ratings_link.book'
)
.
label
(
'count'
),
entries
=
calibre_db
.
session
.
query
(
db
.
Ratings
,
func
.
count
(
'books_ratings_link.book'
)
.
label
(
'count'
),
(
db
.
Ratings
.
rating
/
2
)
.
label
(
'name'
))
\
(
db
.
Ratings
.
rating
/
2
)
.
label
(
'name'
))
\
.
join
(
db
.
books_ratings_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
books_ratings_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
group_by
(
text
(
'books_ratings_link.rating'
))
.
order_by
(
order
)
.
all
()
.
group_by
(
text
(
'books_ratings_link.rating'
))
.
order_by
(
order
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
list
(),
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
list
(),
title
=
_
(
u"Ratings list"
),
page
=
"ratingslist"
,
data
=
"ratings"
)
title
=
_
(
u"Ratings list"
),
page
=
"ratingslist"
,
data
=
"ratings"
,
order
=
order_no
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -908,15 +923,17 @@ def formats_list():
...
@@ -908,15 +923,17 @@ def formats_list():
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_FORMAT
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_FORMAT
):
if
current_user
.
get_view_property
(
'ratings'
,
'dir'
)
==
'desc'
:
if
current_user
.
get_view_property
(
'ratings'
,
'dir'
)
==
'desc'
:
order
=
db
.
Data
.
format
.
desc
()
order
=
db
.
Data
.
format
.
desc
()
order_no
=
0
else
:
else
:
order
=
db
.
Data
.
format
.
asc
()
order
=
db
.
Data
.
format
.
asc
()
order_no
=
1
entries
=
calibre_db
.
session
.
query
(
db
.
Data
,
entries
=
calibre_db
.
session
.
query
(
db
.
Data
,
func
.
count
(
'data.book'
)
.
label
(
'count'
),
func
.
count
(
'data.book'
)
.
label
(
'count'
),
db
.
Data
.
format
.
label
(
'format'
))
\
db
.
Data
.
format
.
label
(
'format'
))
\
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
group_by
(
db
.
Data
.
format
)
.
order_by
(
order
)
.
all
()
.
group_by
(
db
.
Data
.
format
)
.
order_by
(
order
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
list
(),
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
list
(),
title
=
_
(
u"File formats list"
),
page
=
"formatslist"
,
data
=
"formats"
)
title
=
_
(
u"File formats list"
),
page
=
"formatslist"
,
data
=
"formats"
,
order
=
order_no
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
@@ -956,8 +973,10 @@ def category_list():
...
@@ -956,8 +973,10 @@ def category_list():
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_CATEGORY
):
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_CATEGORY
):
if
current_user
.
get_view_property
(
'category'
,
'dir'
)
==
'desc'
:
if
current_user
.
get_view_property
(
'category'
,
'dir'
)
==
'desc'
:
order
=
db
.
Tags
.
name
.
desc
()
order
=
db
.
Tags
.
name
.
desc
()
order_no
=
0
else
:
else
:
order
=
db
.
Tags
.
name
.
asc
()
order
=
db
.
Tags
.
name
.
asc
()
order_no
=
1
entries
=
calibre_db
.
session
.
query
(
db
.
Tags
,
func
.
count
(
'books_tags_link.book'
)
.
label
(
'count'
))
\
entries
=
calibre_db
.
session
.
query
(
db
.
Tags
,
func
.
count
(
'books_tags_link.book'
)
.
label
(
'count'
))
\
.
join
(
db
.
books_tags_link
)
.
join
(
db
.
Books
)
.
order_by
(
order
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
books_tags_link
)
.
join
(
db
.
Books
)
.
order_by
(
order
)
.
filter
(
calibre_db
.
common_filters
())
\
.
group_by
(
text
(
'books_tags_link.tag'
))
.
all
()
.
group_by
(
text
(
'books_tags_link.tag'
))
.
all
()
...
@@ -965,7 +984,7 @@ def category_list():
...
@@ -965,7 +984,7 @@ def category_list():
.
join
(
db
.
books_tags_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
join
(
db
.
books_tags_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Tags
.
name
,
1
,
1
)))
.
all
()
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Tags
.
name
,
1
,
1
)))
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
charlist
,
title
=
_
(
u"Categories"
),
page
=
"catlist"
,
data
=
"category"
)
title
=
_
(
u"Categories"
),
page
=
"catlist"
,
data
=
"category"
,
order
=
order_no
)
else
:
else
:
abort
(
404
)
abort
(
404
)
...
...
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