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
2d73f541
Commit
2d73f541
authored
Apr 08, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix sort books list and user list
Prevent transferring password hash to client
parent
7561eabe
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
17 deletions
+29
-17
admin.py
cps/admin.py
+10
-3
config_sql.py
cps/config_sql.py
+1
-1
db.py
cps/db.py
+2
-2
gdriveutils.py
cps/gdriveutils.py
+1
-1
table.js
cps/static/js/table.js
+9
-5
ub.py
cps/ub.py
+1
-1
web.py
cps/web.py
+5
-4
No files found.
cps/admin.py
View file @
2d73f541
...
@@ -37,7 +37,7 @@ from flask_babel import gettext as _
...
@@ -37,7 +37,7 @@ from flask_babel import gettext as _
from
sqlalchemy
import
and_
from
sqlalchemy
import
and_
from
sqlalchemy.orm.attributes
import
flag_modified
from
sqlalchemy.orm.attributes
import
flag_modified
from
sqlalchemy.exc
import
IntegrityError
,
OperationalError
,
InvalidRequestError
from
sqlalchemy.exc
import
IntegrityError
,
OperationalError
,
InvalidRequestError
from
sqlalchemy.sql.expression
import
func
,
or_
from
sqlalchemy.sql.expression
import
func
,
or_
,
text
from
.
import
constants
,
logger
,
helper
,
services
from
.
import
constants
,
logger
,
helper
,
services
from
.cli
import
filepicker
from
.cli
import
filepicker
...
@@ -244,6 +244,13 @@ def list_users():
...
@@ -244,6 +244,13 @@ def list_users():
off
=
request
.
args
.
get
(
"offset"
)
or
0
off
=
request
.
args
.
get
(
"offset"
)
or
0
limit
=
request
.
args
.
get
(
"limit"
)
or
10
limit
=
request
.
args
.
get
(
"limit"
)
or
10
search
=
request
.
args
.
get
(
"search"
)
search
=
request
.
args
.
get
(
"search"
)
sort
=
request
.
args
.
get
(
"sort"
)
order
=
request
.
args
.
get
(
"order"
)
if
sort
and
order
:
order
=
text
(
sort
+
" "
+
order
)
else
:
order
=
ub
.
User
.
name
.
desc
()
all_user
=
ub
.
session
.
query
(
ub
.
User
)
all_user
=
ub
.
session
.
query
(
ub
.
User
)
if
not
config
.
config_anonbrowse
:
if
not
config
.
config_anonbrowse
:
all_user
=
all_user
.
filter
(
ub
.
User
.
role
.
op
(
'&'
)(
constants
.
ROLE_ANONYMOUS
)
!=
constants
.
ROLE_ANONYMOUS
)
all_user
=
all_user
.
filter
(
ub
.
User
.
role
.
op
(
'&'
)(
constants
.
ROLE_ANONYMOUS
)
!=
constants
.
ROLE_ANONYMOUS
)
...
@@ -252,10 +259,10 @@ def list_users():
...
@@ -252,10 +259,10 @@ def list_users():
users
=
all_user
.
filter
(
or_
(
func
.
lower
(
ub
.
User
.
name
)
.
ilike
(
"
%
"
+
search
+
"
%
"
),
users
=
all_user
.
filter
(
or_
(
func
.
lower
(
ub
.
User
.
name
)
.
ilike
(
"
%
"
+
search
+
"
%
"
),
func
.
lower
(
ub
.
User
.
kindle_mail
)
.
ilike
(
"
%
"
+
search
+
"
%
"
),
func
.
lower
(
ub
.
User
.
kindle_mail
)
.
ilike
(
"
%
"
+
search
+
"
%
"
),
func
.
lower
(
ub
.
User
.
email
)
.
ilike
(
"
%
"
+
search
+
"
%
"
)))
\
func
.
lower
(
ub
.
User
.
email
)
.
ilike
(
"
%
"
+
search
+
"
%
"
)))
\
.
offset
(
off
)
.
limit
(
limit
)
.
all
()
.
o
rder_by
(
order
)
.
o
ffset
(
off
)
.
limit
(
limit
)
.
all
()
filtered_count
=
len
(
users
)
filtered_count
=
len
(
users
)
else
:
else
:
users
=
all_user
.
offset
(
off
)
.
limit
(
limit
)
.
all
()
users
=
all_user
.
o
rder_by
(
order
)
.
o
ffset
(
off
)
.
limit
(
limit
)
.
all
()
filtered_count
=
total_count
filtered_count
=
total_count
for
user
in
users
:
for
user
in
users
:
...
...
cps/config_sql.py
View file @
2d73f541
...
@@ -24,7 +24,7 @@ import sys
...
@@ -24,7 +24,7 @@ import sys
from
sqlalchemy
import
exc
,
Column
,
String
,
Integer
,
SmallInteger
,
Boolean
,
BLOB
,
JSON
from
sqlalchemy
import
exc
,
Column
,
String
,
Integer
,
SmallInteger
,
Boolean
,
BLOB
,
JSON
from
sqlalchemy.exc
import
OperationalError
from
sqlalchemy.exc
import
OperationalError
try
:
try
:
# Compability with sqlalchemy 2.0
# Compa
ti
bility with sqlalchemy 2.0
from
sqlalchemy.orm
import
declarative_base
from
sqlalchemy.orm
import
declarative_base
except
ImportError
:
except
ImportError
:
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
...
...
cps/db.py
View file @
2d73f541
...
@@ -33,7 +33,7 @@ from sqlalchemy.orm.collections import InstrumentedList
...
@@ -33,7 +33,7 @@ from sqlalchemy.orm.collections import InstrumentedList
from
sqlalchemy.ext.declarative
import
DeclarativeMeta
from
sqlalchemy.ext.declarative
import
DeclarativeMeta
from
sqlalchemy.exc
import
OperationalError
from
sqlalchemy.exc
import
OperationalError
try
:
try
:
# Compability with sqlalchemy 2.0
# Compa
ti
bility with sqlalchemy 2.0
from
sqlalchemy.orm
import
declarative_base
from
sqlalchemy.orm
import
declarative_base
except
ImportError
:
except
ImportError
:
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
...
@@ -393,7 +393,7 @@ class AlchemyEncoder(json.JSONEncoder):
...
@@ -393,7 +393,7 @@ class AlchemyEncoder(json.JSONEncoder):
if
isinstance
(
o
.
__class__
,
DeclarativeMeta
):
if
isinstance
(
o
.
__class__
,
DeclarativeMeta
):
# an SQLAlchemy class
# an SQLAlchemy class
fields
=
{}
fields
=
{}
for
field
in
[
x
for
x
in
dir
(
o
)
if
not
x
.
startswith
(
'_'
)
and
x
!=
'metadata'
]:
for
field
in
[
x
for
x
in
dir
(
o
)
if
not
x
.
startswith
(
'_'
)
and
x
!=
'metadata'
and
x
!=
"password"
]:
if
field
==
'books'
:
if
field
==
'books'
:
continue
continue
data
=
o
.
__getattribute__
(
field
)
data
=
o
.
__getattribute__
(
field
)
...
...
cps/gdriveutils.py
View file @
2d73f541
...
@@ -29,7 +29,7 @@ from sqlalchemy import Column, UniqueConstraint
...
@@ -29,7 +29,7 @@ from sqlalchemy import Column, UniqueConstraint
from
sqlalchemy
import
String
,
Integer
from
sqlalchemy
import
String
,
Integer
from
sqlalchemy.orm
import
sessionmaker
,
scoped_session
from
sqlalchemy.orm
import
sessionmaker
,
scoped_session
try
:
try
:
# Compability with sqlalchemy 2.0
# Compa
ti
bility with sqlalchemy 2.0
from
sqlalchemy.orm
import
declarative_base
from
sqlalchemy.orm
import
declarative_base
except
ImportError
:
except
ImportError
:
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
...
...
cps/static/js/table.js
View file @
2d73f541
...
@@ -460,8 +460,7 @@ $(function() {
...
@@ -460,8 +460,7 @@ $(function() {
$
(
"input[data-name='passwd_role'][data-pk='"
+
guest
.
data
(
"pk"
)
+
"']"
).
prop
(
"disabled"
,
true
);
$
(
"input[data-name='passwd_role'][data-pk='"
+
guest
.
data
(
"pk"
)
+
"']"
).
prop
(
"disabled"
,
true
);
$
(
"input[data-name='edit_shelf_role'][data-pk='"
+
guest
.
data
(
"pk"
)
+
"']"
).
prop
(
"disabled"
,
true
);
$
(
"input[data-name='edit_shelf_role'][data-pk='"
+
guest
.
data
(
"pk"
)
+
"']"
).
prop
(
"disabled"
,
true
);
$
(
"input[data-name='sidebar_read_and_unread'][data-pk='"
+
guest
.
data
(
"pk"
)
+
"']"
).
prop
(
"disabled"
,
true
);
$
(
"input[data-name='sidebar_read_and_unread'][data-pk='"
+
guest
.
data
(
"pk"
)
+
"']"
).
prop
(
"disabled"
,
true
);
// ToDo: Disable delete
$
(
".user-remove[data-pk='"
+
guest
.
data
(
"pk"
)
+
"']"
).
prop
(
"disabled"
,
true
);
},
},
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line no-unused-vars
...
@@ -604,7 +603,7 @@ function EbookActions (value, row) {
...
@@ -604,7 +603,7 @@ function EbookActions (value, row) {
/* Function for deleting books */
/* Function for deleting books */
function
UserActions
(
value
,
row
)
{
function
UserActions
(
value
,
row
)
{
return
[
return
[
"<div class=
\"
user-remove
\"
data-target=
\"
#GeneralDeleteModal
\"
title=
\"
Remove
\"
>"
,
"<div class=
\"
user-remove
\"
data-
pk=
\"
"
+
row
.
id
+
"
\"
data-
target=
\"
#GeneralDeleteModal
\"
title=
\"
Remove
\"
>"
,
"<i class=
\"
glyphicon glyphicon-trash
\"
></i>"
,
"<i class=
\"
glyphicon glyphicon-trash
\"
></i>"
,
"</div>"
"</div>"
].
join
(
""
);
].
join
(
""
);
...
@@ -624,9 +623,9 @@ function singleUserFormatter(value, row) {
...
@@ -624,9 +623,9 @@ function singleUserFormatter(value, row) {
function
checkboxFormatter
(
value
,
row
,
index
){
function
checkboxFormatter
(
value
,
row
,
index
){
if
(
value
&
this
.
column
)
if
(
value
&
this
.
column
)
return
'<input type="checkbox" class="chk" data-pk="'
+
row
.
id
+
'" data-name="'
+
this
.
name
+
'" checked onchange="checkboxChange(this, '
+
row
.
id
+
',
\'
'
+
this
.
field
+
'
\'
, '
+
this
.
column
+
')">'
;
return
'<input type="checkbox" class="chk" data-pk="'
+
row
.
id
+
'" data-name="'
+
this
.
field
+
'" checked onchange="checkboxChange(this, '
+
row
.
id
+
',
\'
'
+
this
.
name
+
'
\'
, '
+
this
.
column
+
')">'
;
else
else
return
'<input type="checkbox" class="chk" data-pk="'
+
row
.
id
+
'" data-name="'
+
this
.
name
+
'" onchange="checkboxChange(this, '
+
row
.
id
+
',
\'
'
+
this
.
field
+
'
\'
, '
+
this
.
column
+
')">'
;
return
'<input type="checkbox" class="chk" data-pk="'
+
row
.
id
+
'" data-name="'
+
this
.
field
+
'" onchange="checkboxChange(this, '
+
row
.
id
+
',
\'
'
+
this
.
name
+
'
\'
, '
+
this
.
column
+
')">'
;
}
}
function
checkboxChange
(
checkbox
,
userId
,
field
,
field_index
)
{
function
checkboxChange
(
checkbox
,
userId
,
field
,
field_index
)
{
...
@@ -733,6 +732,11 @@ function user_handle (userId) {
...
@@ -733,6 +732,11 @@ function user_handle (userId) {
});
});
}
}
function
checkboxSorter
(
a
,
b
,
c
,
d
)
{
return
a
-
b
}
function
test
(){
function
test
(){
console
.
log
(
"hello"
);
console
.
log
(
"hello"
);
}
}
cps/ub.py
View file @
2d73f541
...
@@ -44,7 +44,7 @@ from sqlalchemy import String, Integer, SmallInteger, Boolean, DateTime, Float,
...
@@ -44,7 +44,7 @@ from sqlalchemy import String, Integer, SmallInteger, Boolean, DateTime, Float,
from
sqlalchemy.orm.attributes
import
flag_modified
from
sqlalchemy.orm.attributes
import
flag_modified
from
sqlalchemy.sql.expression
import
func
from
sqlalchemy.sql.expression
import
func
try
:
try
:
# Compability with sqlalchemy 2.0
# Compa
ti
bility with sqlalchemy 2.0
from
sqlalchemy.orm
import
declarative_base
from
sqlalchemy.orm
import
declarative_base
except
ImportError
:
except
ImportError
:
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
...
...
cps/web.py
View file @
2d73f541
...
@@ -755,11 +755,12 @@ def books_table():
...
@@ -755,11 +755,12 @@ def books_table():
def
list_books
():
def
list_books
():
off
=
request
.
args
.
get
(
"offset"
)
or
0
off
=
request
.
args
.
get
(
"offset"
)
or
0
limit
=
request
.
args
.
get
(
"limit"
)
or
config
.
config_books_per_page
limit
=
request
.
args
.
get
(
"limit"
)
or
config
.
config_books_per_page
# sort = request.args.get("sort")
sort
=
request
.
args
.
get
(
"sort"
)
if
request
.
args
.
get
(
"order"
)
==
'desc'
:
order
=
request
.
args
.
get
(
"order"
)
order
=
[
db
.
Books
.
timestamp
.
desc
()]
if
sort
and
order
:
order
=
[
text
(
sort
+
" "
+
order
)]
else
:
else
:
order
=
[
db
.
Books
.
timestamp
.
a
sc
()]
order
=
[
db
.
Books
.
timestamp
.
de
sc
()]
search
=
request
.
args
.
get
(
"search"
)
search
=
request
.
args
.
get
(
"search"
)
total_count
=
calibre_db
.
session
.
query
(
db
.
Books
)
.
count
()
total_count
=
calibre_db
.
session
.
query
(
db
.
Books
)
.
count
()
if
search
:
if
search
:
...
...
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