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
01381488
Commit
01381488
authored
Dec 28, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes from tests
parent
62e8bee2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1283 additions
and
3972 deletions
+1283
-3972
admin.py
cps/admin.py
+8
-2
config_sql.py
cps/config_sql.py
+5
-1
constants.py
cps/constants.py
+2
-0
helper.py
cps/helper.py
+3
-1
server.py
cps/server.py
+1
-1
user_edit.html
cps/templates/user_edit.html
+1
-1
web.py
cps/web.py
+31
-13
Calibre-Web TestSummary.html
test/Calibre-Web TestSummary.html
+1232
-3953
No files found.
cps/admin.py
View file @
01381488
...
...
@@ -639,15 +639,20 @@ def edit_user(user_id):
@
admi
.
route
(
"/admin/resetpassword/<int:user_id>"
)
@
login_required
@
admin_required
def
reset_password
(
user_id
):
def
reset_
user_
password
(
user_id
):
if
not
config
.
config_public_reg
:
abort
(
404
)
if
current_user
is
not
None
and
current_user
.
is_authenticated
:
ret
,
message
=
reset_password
(
user_id
)
if
ret
==
1
:
log
.
debug
(
u"Password for user
%(user)
s reset"
,
user
=
message
)
flash
(
_
(
u"Password for user
%(user)
s reset"
,
user
=
message
),
category
=
"success"
)
else
:
elif
ret
==
0
:
log
.
error
(
u"An unknown error occurred. Please try again later."
)
flash
(
_
(
u"An unknown error occurred. Please try again later."
),
category
=
"error"
)
else
:
log
.
error
(
u"Please configure the SMTP mail settings first..."
)
flash
(
_
(
u"Please configure the SMTP mail settings first..."
),
category
=
"error"
)
return
redirect
(
url_for
(
'admin.admin'
))
...
...
@@ -681,6 +686,7 @@ def send_logfile(logtype):
@
admi
.
route
(
"/get_update_status"
,
methods
=
[
'GET'
])
@
login_required_if_no_ano
def
get_update_status
():
log
.
info
(
u"Update status requested"
)
return
updater_thread
.
get_available_updates
(
request
.
method
,
locale
=
get_locale
())
...
...
cps/config_sql.py
View file @
01381488
...
...
@@ -38,7 +38,7 @@ class _Settings(_Base):
__tablename__
=
'settings'
id
=
Column
(
Integer
,
primary_key
=
True
)
mail_server
=
Column
(
String
,
default
=
'mail.example.org'
)
mail_server
=
Column
(
String
,
default
=
constants
.
DEFAULT_MAIL_SERVER
)
mail_port
=
Column
(
Integer
,
default
=
25
)
mail_use_ssl
=
Column
(
SmallInteger
,
default
=
0
)
mail_login
=
Column
(
String
,
default
=
'mail@example.com'
)
...
...
@@ -189,6 +189,10 @@ class _ConfigSQL(object):
def
get_mail_settings
(
self
):
return
{
k
:
v
for
k
,
v
in
self
.
__dict__
.
items
()
if
k
.
startswith
(
'mail_'
)}
def
get_mail_server_configured
(
self
):
return
not
bool
(
self
.
mail_server
==
constants
.
DEFAULT_MAIL_SERVER
)
def
set_from_dictionary
(
self
,
dictionary
,
field
,
convertor
=
None
,
default
=
None
):
'''Possibly updates a field of this object.
The new value, if present, is grabbed from the given dictionary, and optionally passed through a convertor.
...
...
cps/constants.py
View file @
01381488
...
...
@@ -94,6 +94,7 @@ LOGIN_LDAP = 1
LOGIN_OAUTH
=
2
# LOGIN_OAUTH_GOOGLE = 3
DEFAULT_MAIL_SERVER
=
"mail.example.org"
DEFAULT_PASSWORD
=
"admin123"
DEFAULT_PORT
=
8083
...
...
@@ -105,6 +106,7 @@ except ValueError:
del
env_CALIBRE_PORT
EXTENSIONS_AUDIO
=
{
'mp3'
,
'm4a'
,
'm4b'
}
EXTENSIONS_CONVERT
=
{
'pdf'
,
'epub'
,
'mobi'
,
'azw3'
,
'docx'
,
'rtf'
,
'fb2'
,
'lit'
,
'lrf'
,
'txt'
,
'htmlz'
,
'rtf'
,
'odt'
}
EXTENSIONS_UPLOAD
=
{
'txt'
,
'pdf'
,
'epub'
,
'mobi'
,
'azw'
,
'azw3'
,
'cbr'
,
'cbz'
,
'cbt'
,
'djvu'
,
'prc'
,
'doc'
,
'docx'
,
...
...
cps/helper.py
View file @
01381488
...
...
@@ -125,7 +125,7 @@ def send_registration_mail(e_mail, user_name, default_password, resend=False):
if
not
resend
:
text
+=
"Your new account at Calibre-Web has been created. Thanks for joining us!
\r\n
"
text
+=
"Please log in to your account using the following informations:
\r\n
"
text
+=
"User name:
%
s
\n
"
%
user_name
text
+=
"User name:
%
s
\
r\
n
"
%
user_name
text
+=
"Password:
%
s
\r\n
"
%
default_password
text
+=
"Don't forget to change your password after first login.
\r\n
"
text
+=
"Sincerely
\r\n\r\n
"
...
...
@@ -416,6 +416,8 @@ def reset_password(user_id):
existing_user
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
id
==
user_id
)
.
first
()
password
=
generate_random_password
()
existing_user
.
password
=
generate_password_hash
(
password
)
if
not
config
.
get_mail_server_configured
():
return
(
2
,
None
)
try
:
ub
.
session
.
commit
()
send_registration_mail
(
existing_user
.
email
,
existing_user
.
nickname
,
password
,
True
)
...
...
cps/server.py
View file @
01381488
...
...
@@ -24,7 +24,7 @@ import signal
import
socket
try
:
from
gevent.pywsgi
import
WSGIServer
from
gevent.py
s
wsgi
import
WSGIServer
from
gevent.pool
import
Pool
from
gevent
import
__version__
as
_version
VERSION
=
'Gevent '
+
_version
...
...
cps/templates/user_edit.html
View file @
01381488
...
...
@@ -15,7 +15,7 @@
</div>
{% if ( g.user and g.user.role_passwd() or g.user.role_admin() ) and not content.role_anonymous() %}
{% if g.user and g.user.role_admin() and g.allow_registration and not new_user and not profile %}
<div
class=
"btn btn-default"
id=
"resend_password"
><a
href=
"{{url_for('admin.reset_password', user_id = content.id) }}"
>
{{_('Reset user Password')}}
</a></div>
<div
class=
"btn btn-default"
id=
"resend_password"
><a
href=
"{{url_for('admin.reset_
user_
password', user_id = content.id) }}"
>
{{_('Reset user Password')}}
</a></div>
{% else %}
<div
class=
"form-group"
>
<label
for=
"password"
>
{{_('Password')}}
</label>
...
...
cps/web.py
View file @
01381488
This diff is collapsed.
Click to expand it.
test/Calibre-Web TestSummary.html
View file @
01381488
This diff is collapsed.
Click to expand it.
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