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
b97373bf
Commit
b97373bf
authored
May 01, 2021
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved error handling for disapearing custom column linked to read status
parent
c0b561cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
admin.py
cps/admin.py
+2
-2
details.js
cps/static/js/details.js
+15
-1
web.py
cps/web.py
+15
-7
No files found.
cps/admin.py
View file @
b97373bf
...
...
@@ -474,14 +474,14 @@ def update_table_settings():
return
""
def
check_valid_read_column
(
column
):
if
column
is
not
"0"
:
if
column
!=
"0"
:
if
not
calibre_db
.
session
.
query
(
db
.
Custom_Columns
)
.
filter
(
db
.
Custom_Columns
.
id
==
column
)
\
.
filter
(
and_
(
db
.
Custom_Columns
.
datatype
==
'bool'
,
db
.
Custom_Columns
.
mark_for_delete
==
0
))
.
all
():
return
False
return
True
def
check_valid_restricted_column
(
column
):
if
column
is
not
"0"
:
if
column
!=
"0"
:
if
not
calibre_db
.
session
.
query
(
db
.
Custom_Columns
)
.
filter
(
db
.
Custom_Columns
.
id
==
column
)
\
.
filter
(
and_
(
db
.
Custom_Columns
.
datatype
==
'text'
,
db
.
Custom_Columns
.
mark_for_delete
==
0
))
.
all
():
return
False
...
...
cps/static/js/details.js
View file @
b97373bf
...
...
@@ -22,7 +22,21 @@ $(function() {
});
$
(
"#have_read_cb"
).
on
(
"change"
,
function
()
{
$
(
this
).
closest
(
"form"
).
submit
();
$
.
post
({
url
:
this
.
closest
(
"form"
).
action
,
error
:
function
(
response
)
{
var
data
=
[{
type
:
"danger"
,
message
:
response
.
responseText
}]
$
(
"#flash_success"
).
remove
();
$
(
"#flash_danger"
).
remove
();
if
(
!
jQuery
.
isEmptyObject
(
data
))
{
data
.
forEach
(
function
(
item
)
{
$
(
".navbar"
).
after
(
'<div class="row-fluid text-center" style="margin-top: -20px;">'
+
'<div id="flash_'
+
item
.
type
+
'" class="alert alert-'
+
item
.
type
+
'">'
+
item
.
message
+
'</div>'
+
'</div>'
);
});
}
}
});
});
$
(
function
()
{
...
...
cps/web.py
View file @
b97373bf
...
...
@@ -185,10 +185,11 @@ def toggle_read(book_id):
calibre_db
.
session
.
commit
()
except
(
KeyError
,
AttributeError
):
log
.
error
(
u"Custom Column No.
%
d is not exisiting in calibre database"
,
config
.
config_read_column
)
return
"Custom Column No.{} is not exisiting in calibre database"
.
format
(
config
.
config_read_column
),
400
except
(
OperationalError
,
InvalidRequestError
)
as
e
:
calibre_db
.
session
.
rollback
()
log
.
error
(
u"Read status could not set:
%
e"
,
e
)
return
"Read status could not set: {}"
.
format
(
e
),
400
return
""
@
web
.
route
(
"/ajax/togglearchived/<int:book_id>"
,
methods
=
[
'POST'
])
...
...
@@ -1117,12 +1118,19 @@ def adv_search_ratings(q, rating_high, rating_low):
def
adv_search_read_status
(
q
,
read_status
):
if
read_status
:
if
config
.
config_read_column
:
if
read_status
==
"True"
:
q
=
q
.
join
(
db
.
cc_classes
[
config
.
config_read_column
],
isouter
=
True
)
\
.
filter
(
db
.
cc_classes
[
config
.
config_read_column
]
.
value
==
True
)
else
:
q
=
q
.
join
(
db
.
cc_classes
[
config
.
config_read_column
],
isouter
=
True
)
\
.
filter
(
coalesce
(
db
.
cc_classes
[
config
.
config_read_column
]
.
value
,
False
)
!=
True
)
try
:
if
read_status
==
"True"
:
q
=
q
.
join
(
db
.
cc_classes
[
config
.
config_read_column
],
isouter
=
True
)
\
.
filter
(
db
.
cc_classes
[
config
.
config_read_column
]
.
value
==
True
)
else
:
q
=
q
.
join
(
db
.
cc_classes
[
config
.
config_read_column
],
isouter
=
True
)
\
.
filter
(
coalesce
(
db
.
cc_classes
[
config
.
config_read_column
]
.
value
,
False
)
!=
True
)
except
(
KeyError
,
AttributeError
):
log
.
error
(
u"Custom Column No.
%
d is not exisiting in calibre database"
,
config
.
config_read_column
)
flash
(
_
(
"Custom Column No.
%(column)
d is not existing in calibre database"
,
column
=
config
.
config_read_column
),
category
=
"error"
)
return
q
else
:
if
read_status
==
"True"
:
q
=
q
.
join
(
ub
.
ReadBook
,
db
.
Books
.
id
==
ub
.
ReadBook
.
book_id
,
isouter
=
True
)
\
...
...
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