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
bff86f02
Commit
bff86f02
authored
Feb 09, 2017
by
idalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
settings for default role of new register user
parent
df2eb824
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
config_edit.html
cps/templates/config_edit.html
+20
-0
ub.py
cps/ub.py
+33
-0
web.py
cps/web.py
+13
-1
No files found.
cps/templates/config_edit.html
View file @
bff86f02
...
@@ -49,6 +49,26 @@
...
@@ -49,6 +49,26 @@
<input
type=
"checkbox"
id=
"config_public_reg"
name=
"config_public_reg"
{%
if
content
.
config_public_reg
%}
checked
{%
endif
%}
>
<input
type=
"checkbox"
id=
"config_public_reg"
name=
"config_public_reg"
{%
if
content
.
config_public_reg
%}
checked
{%
endif
%}
>
<label
for=
"config_public_reg"
>
{{_('Enable public registration')}}
</label>
<label
for=
"config_public_reg"
>
{{_('Enable public registration')}}
</label>
</div>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"admin_role"
id=
"admin_role"
{%
if
content
.
role_admin
()
%}
checked
{%
endif
%}
>
<label
for=
"admin_role"
>
{{_('Admin user')}}
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"download_role"
id=
"download_role"
{%
if
content
.
role_download
()
%}
checked
{%
endif
%}
>
<label
for=
"download_role"
>
{{_('Allow Downloads')}}
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"upload_role"
id=
"upload_role"
{%
if
content
.
role_upload
()
%}
checked
{%
endif
%}
>
<label
for=
"upload_role"
>
{{_('Allow Uploads')}}
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"edit_role"
id=
"edit_role"
{%
if
content
.
role_edit
()
%}
checked
{%
endif
%}
>
<label
for=
"edit_role"
>
{{_('Allow Edit')}}
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"passwd_role"
id=
"passwd_role"
{%
if
content
.
role_passwd
()
%}
checked
{%
endif
%}
>
<label
for=
"passwd_role"
>
{{_('Allow Changing Password')}}
</label>
</div>
<button
type=
"submit"
class=
"btn btn-default"
>
{{_('Submit')}}
</button>
<button
type=
"submit"
class=
"btn btn-default"
>
{{_('Submit')}}
</button>
{% if not origin %}
{% if not origin %}
<a
href=
"{{ url_for('admin') }}"
class=
"btn btn-default"
>
{{_('Back')}}
</a>
<a
href=
"{{ url_for('admin') }}"
class=
"btn btn-default"
>
{{_('Back')}}
</a>
...
...
cps/ub.py
View file @
bff86f02
...
@@ -262,6 +262,7 @@ class Settings(Base):
...
@@ -262,6 +262,7 @@ class Settings(Base):
config_uploading
=
Column
(
SmallInteger
,
default
=
0
)
config_uploading
=
Column
(
SmallInteger
,
default
=
0
)
config_anonbrowse
=
Column
(
SmallInteger
,
default
=
0
)
config_anonbrowse
=
Column
(
SmallInteger
,
default
=
0
)
config_public_reg
=
Column
(
SmallInteger
,
default
=
0
)
config_public_reg
=
Column
(
SmallInteger
,
default
=
0
)
config_default_role
=
Column
(
SmallInteger
,
default
=
0
)
def
__repr__
(
self
):
def
__repr__
(
self
):
pass
pass
...
@@ -287,6 +288,7 @@ class Config:
...
@@ -287,6 +288,7 @@ class Config:
self
.
config_uploading
=
data
.
config_uploading
self
.
config_uploading
=
data
.
config_uploading
self
.
config_anonbrowse
=
data
.
config_anonbrowse
self
.
config_anonbrowse
=
data
.
config_anonbrowse
self
.
config_public_reg
=
data
.
config_public_reg
self
.
config_public_reg
=
data
.
config_public_reg
self
.
config_default_role
=
data
.
config_default_role
if
self
.
config_calibre_dir
is
not
None
:
# and (self.db_configured is None or self.db_configured is True):
if
self
.
config_calibre_dir
is
not
None
:
# and (self.db_configured is None or self.db_configured is True):
self
.
db_configured
=
True
self
.
db_configured
=
True
else
:
else
:
...
@@ -296,6 +298,36 @@ class Config:
...
@@ -296,6 +298,36 @@ class Config:
def
get_main_dir
(
self
):
def
get_main_dir
(
self
):
return
self
.
config_main_dir
return
self
.
config_main_dir
def
role_admin
(
self
):
if
self
.
config_default_role
is
not
None
:
return
True
if
self
.
config_default_role
&
ROLE_ADMIN
==
ROLE_ADMIN
else
False
else
:
return
False
def
role_download
(
self
):
if
self
.
config_default_role
is
not
None
:
return
True
if
self
.
config_default_role
&
ROLE_DOWNLOAD
==
ROLE_DOWNLOAD
else
False
else
:
return
False
def
role_upload
(
self
):
if
self
.
config_default_role
is
not
None
:
return
True
if
self
.
config_default_role
&
ROLE_UPLOAD
==
ROLE_UPLOAD
else
False
else
:
return
False
def
role_edit
(
self
):
if
self
.
config_default_role
is
not
None
:
return
True
if
self
.
config_default_role
&
ROLE_EDIT
==
ROLE_EDIT
else
False
else
:
return
False
def
role_passwd
(
self
):
if
self
.
config_default_role
is
not
None
:
return
True
if
self
.
config_default_role
&
ROLE_PASSWD
==
ROLE_PASSWD
else
False
else
:
return
False
def
get_Log_Level
(
self
):
def
get_Log_Level
(
self
):
ret_value
=
""
ret_value
=
""
if
self
.
config_log_level
==
logging
.
INFO
:
if
self
.
config_log_level
==
logging
.
INFO
:
...
@@ -337,6 +369,7 @@ def migrate_Database():
...
@@ -337,6 +369,7 @@ def migrate_Database():
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_uploading` SmallInteger DEFAULT 0"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_uploading` SmallInteger DEFAULT 0"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_anonbrowse` SmallInteger DEFAULT 0"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_anonbrowse` SmallInteger DEFAULT 0"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_public_reg` SmallInteger DEFAULT 0"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_public_reg` SmallInteger DEFAULT 0"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_default_role` SmallInteger DEFAULT 0"
)
session
.
commit
()
session
.
commit
()
try
:
try
:
session
.
query
(
exists
()
.
where
(
BookShelf
.
order
))
.
scalar
()
session
.
query
(
exists
()
.
where
(
BookShelf
.
order
))
.
scalar
()
...
...
cps/web.py
View file @
bff86f02
...
@@ -1271,7 +1271,7 @@ def register():
...
@@ -1271,7 +1271,7 @@ def register():
content
.
password
=
generate_password_hash
(
to_save
[
"password"
])
content
.
password
=
generate_password_hash
(
to_save
[
"password"
])
content
.
nickname
=
to_save
[
"nickname"
]
content
.
nickname
=
to_save
[
"nickname"
]
content
.
email
=
to_save
[
"email"
]
content
.
email
=
to_save
[
"email"
]
content
.
role
=
0
content
.
role
=
config
.
config_default_role
try
:
try
:
ub
.
session
.
add
(
content
)
ub
.
session
.
add
(
content
)
ub
.
session
.
commit
()
ub
.
session
.
commit
()
...
@@ -1635,6 +1635,18 @@ def configuration_helper(origin):
...
@@ -1635,6 +1635,18 @@ def configuration_helper(origin):
content
.
config_anonbrowse
=
1
content
.
config_anonbrowse
=
1
if
"config_public_reg"
in
to_save
and
to_save
[
"config_public_reg"
]
==
"on"
:
if
"config_public_reg"
in
to_save
and
to_save
[
"config_public_reg"
]
==
"on"
:
content
.
config_public_reg
=
1
content
.
config_public_reg
=
1
content
.
config_default_role
=
0
if
"admin_role"
in
to_save
:
content
.
config_default_role
=
content
.
config_default_role
+
ub
.
ROLE_ADMIN
if
"download_role"
in
to_save
:
content
.
config_default_role
=
content
.
config_default_role
+
ub
.
ROLE_DOWNLOAD
if
"upload_role"
in
to_save
:
content
.
config_default_role
=
content
.
config_default_role
+
ub
.
ROLE_UPLOAD
if
"edit_role"
in
to_save
:
content
.
config_default_role
=
content
.
config_default_role
+
ub
.
ROLE_EDIT
if
"passwd_role"
in
to_save
:
content
.
config_default_role
=
content
.
config_default_role
+
ub
.
ROLE_PASSWD
try
:
try
:
if
db_change
:
if
db_change
:
if
config
.
db_configured
:
if
config
.
db_configured
:
...
...
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