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
98134616
Commit
98134616
authored
Jan 06, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #661 (authors are shown according to the authors sort order)
parent
4dcac075
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
1 deletion
+65
-1
web.py
cps/web.py
+65
-1
No files found.
cps/web.py
View file @
98134616
...
@@ -494,6 +494,21 @@ def speaking_language(languages=None):
...
@@ -494,6 +494,21 @@ def speaking_language(languages=None):
lang
.
name
=
_
(
isoLanguages
.
get
(
part3
=
lang
.
lang_code
)
.
name
)
lang
.
name
=
_
(
isoLanguages
.
get
(
part3
=
lang
.
lang_code
)
.
name
)
return
languages
return
languages
# Orders all Authors in the list according to authors sort
def
order_authors
(
entry
):
sort_authors
=
entry
.
author_sort
.
split
(
'&'
)
authors_ordered
=
list
()
error
=
False
for
auth
in
sort_authors
:
# ToDo: How to handle not found authorname
result
=
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
sort
==
auth
.
lstrip
()
.
strip
())
.
first
()
if
not
result
:
error
=
True
break
authors_ordered
.
append
(
result
)
if
not
error
:
entry
.
authors
=
authors_ordered
return
entry
# Fill indexpage with all requested data from database
# Fill indexpage with all requested data from database
def
fill_indexpage
(
page
,
database
,
db_filter
,
order
,
*
join
):
def
fill_indexpage
(
page
,
database
,
db_filter
,
order
,
*
join
):
...
@@ -508,6 +523,20 @@ def fill_indexpage(page, database, db_filter, order, *join):
...
@@ -508,6 +523,20 @@ def fill_indexpage(page, database, db_filter, order, *join):
.
filter
(
db_filter
)
.
filter
(
common_filters
())
.
all
()))
.
filter
(
db_filter
)
.
filter
(
common_filters
())
.
all
()))
entries
=
db
.
session
.
query
(
database
)
.
join
(
*
join
,
isouter
=
True
)
.
filter
(
db_filter
)
\
entries
=
db
.
session
.
query
(
database
)
.
join
(
*
join
,
isouter
=
True
)
.
filter
(
db_filter
)
\
.
filter
(
common_filters
())
.
order_by
(
*
order
)
.
offset
(
off
)
.
limit
(
config
.
config_books_per_page
)
.
all
()
.
filter
(
common_filters
())
.
order_by
(
*
order
)
.
offset
(
off
)
.
limit
(
config
.
config_books_per_page
)
.
all
()
for
book
in
entries
:
book
=
order_authors
(
book
)
'''sort_authors = book.author_sort.split('&')
authors_ordered = list()
error = False
for auth in sort_authors:
# ToDo: How to handle not found authorname
result = db.session.query(db.Authors).filter(db.Authors.sort == auth.lstrip().strip()).first()
if not result:
error = True
break
authors_ordered.append(result)
if not error:
book.authors = authors_ordered'''
return
entries
,
randm
,
pagination
return
entries
,
randm
,
pagination
...
@@ -1659,6 +1688,20 @@ def show_book(book_id):
...
@@ -1659,6 +1688,20 @@ def show_book(book_id):
entries
.
tags
=
sort
(
entries
.
tags
,
key
=
lambda
tag
:
tag
.
name
)
entries
.
tags
=
sort
(
entries
.
tags
,
key
=
lambda
tag
:
tag
.
name
)
entries
=
order_authors
(
entries
)
'''sort_authors = entries.author_sort.split('&')
authors_ordered = list()
error = False
for auth in sort_authors:
# ToDo: How to handle not found authorname
result = db.session.query(db.Authors).filter(db.Authors.sort == auth.lstrip().strip()).first()
if not result:
error = True
break
authors_ordered.append(result)
if not error:
entries.authors = authors_ordered'''
kindle_list
=
helper
.
check_send_to_kindle
(
entries
)
kindle_list
=
helper
.
check_send_to_kindle
(
entries
)
reader_list
=
helper
.
check_read_formats
(
entries
)
reader_list
=
helper
.
check_read_formats
(
entries
)
...
@@ -3437,6 +3480,20 @@ def render_edit_book(book_id):
...
@@ -3437,6 +3480,20 @@ def render_edit_book(book_id):
for
indx
in
range
(
0
,
len
(
book
.
languages
)):
for
indx
in
range
(
0
,
len
(
book
.
languages
)):
book
.
languages
[
indx
]
.
language_name
=
language_table
[
get_locale
()][
book
.
languages
[
indx
]
.
lang_code
]
book
.
languages
[
indx
]
.
language_name
=
language_table
[
get_locale
()][
book
.
languages
[
indx
]
.
lang_code
]
book
=
order_authors
(
book
)
'''sort_authors = book.author_sort.split('&')
authors_ordered = list()
error = False
for auth in sort_authors:
# ToDo: How to handle not found authorname
result = db.session.query(db.Authors).filter(db.Authors.sort == auth.lstrip().strip()).first()
if not result:
error = True
break
authors_ordered.append(result)
if not error:
book.authors = authors_ordered'''
author_names
=
[]
author_names
=
[]
for
authr
in
book
.
authors
:
for
authr
in
book
.
authors
:
author_names
.
append
(
authr
.
name
.
replace
(
'|'
,
','
))
author_names
.
append
(
authr
.
name
.
replace
(
'|'
,
','
))
...
@@ -3660,9 +3717,16 @@ def edit_book(book_id):
...
@@ -3660,9 +3717,16 @@ def edit_book(book_id):
modify_database_object
(
input_authors
,
book
.
authors
,
db
.
Authors
,
db
.
session
,
'author'
)
modify_database_object
(
input_authors
,
book
.
authors
,
db
.
Authors
,
db
.
session
,
'author'
)
# Search for each author if author is in database, if not, authorname and sorted authorname is generated new
# everything then is assembled for sorted author field in database
sort_authors_list
=
list
()
sort_authors_list
=
list
()
for
inp
in
input_authors
:
for
inp
in
input_authors
:
sort_authors_list
.
append
(
helper
.
get_sorted_author
(
inp
))
stored_author
=
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
name
==
inp
)
.
first
()
if
not
stored_author
:
stored_author
=
helper
.
get_sorted_author
(
inp
)
else
:
stored_author
=
stored_author
.
sort
sort_authors_list
.
append
(
helper
.
get_sorted_author
(
stored_author
))
sort_authors
=
' & '
.
join
(
sort_authors_list
)
sort_authors
=
' & '
.
join
(
sort_authors_list
)
if
book
.
author_sort
!=
sort_authors
:
if
book
.
author_sort
!=
sort_authors
:
edited_books_id
=
book
.
id
edited_books_id
=
book
.
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