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
b596734c
Commit
b596734c
authored
Aug 12, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'adv/mature-content'
parents
8f5bc2a4
aee8aad9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
144 additions
and
67 deletions
+144
-67
config_edit.html
cps/templates/config_edit.html
+7
-0
user_edit.html
cps/templates/user_edit.html
+41
-38
ub.py
cps/ub.py
+16
-1
web.py
cps/web.py
+80
-28
No files found.
cps/templates/config_edit.html
View file @
b596734c
...
...
@@ -72,6 +72,13 @@
<label
for=
"config_title_regex"
>
{{_('Regular expression for title sorting')}}
</label>
<input
type=
"text"
class=
"form-control"
name=
"config_title_regex"
id=
"config_title_regex"
value=
"{% if content.config_title_regex != None %}{{ content.config_title_regex }}{% endif %}"
autocomplete=
"off"
>
</div>
<div
class=
"form-group"
>
<label
for=
"config_mature_content_tags"
>
{{_('Tags for Mature Content')}}
</label>
<input
type=
"text"
class=
"form-control"
name=
"config_mature_content_tags"
id=
"config_mature_content_tags"
value=
"{% if content.config_mature_content_tags != None%}{{ content.config_mature_content_tags }}{% endif %}"
autocomplete=
"off"
>
</div>
<div
class=
"form-group"
>
<label
for=
"config_log_level"
>
{{_('Log Level')}}
</label>
<select
name=
"config_log_level"
id=
"config_log_level"
class=
"form-control"
>
...
...
cps/templates/user_edit.html
View file @
b596734c
...
...
@@ -41,7 +41,10 @@
</select>
</div>
<div
class=
"col-sm-6"
>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"show_mature_content"
id=
"show_mature_content"
{%
if
content
.
mature_content
%}
checked
{%
endif
%}
>
<label
for=
"show_mature_content"
>
{{_('Show mature content')}}
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"show_random"
id=
"show_random"
{%
if
content
.
show_random_books
()
%}
checked
{%
endif
%}
>
<label
for=
"show_random"
>
{{_('Show random books')}}
</label>
...
...
@@ -78,7 +81,7 @@
<input
type=
"checkbox"
name=
"show_detail_random"
id=
"show_detail_random"
{%
if
content
.
show_detail_random
()
%}
checked
{%
endif
%}
>
<label
for=
"show_detail_random"
>
{{_('Show random books in detail view')}}
</label>
</div>
</div>
</div>
<div
class=
"col-sm-6"
>
{% if g.user and g.user.role_admin() and not profile %}
{% if not content.role_anonymous() %}
...
...
cps/ub.py
View file @
b596734c
...
...
@@ -157,6 +157,7 @@ class User(UserBase, Base):
locale
=
Column
(
String
(
2
),
default
=
"en"
)
sidebar_view
=
Column
(
Integer
,
default
=
1
)
default_language
=
Column
(
String
(
3
),
default
=
"all"
)
mature_content
=
Column
(
Boolean
,
default
=
True
)
# Class for anonymous user is derived from User base and complets overrides methods and properties for the
...
...
@@ -266,6 +267,7 @@ class Settings(Base):
config_use_goodreads
=
Column
(
Boolean
)
config_goodreads_api_key
=
Column
(
String
)
config_goodreads_api_secret
=
Column
(
String
)
config_mature_content_tags
=
Column
(
String
)
# type: str
def
__repr__
(
self
):
pass
...
...
@@ -297,7 +299,7 @@ class Config:
self
.
loadSettings
()
def
loadSettings
(
self
):
data
=
session
.
query
(
Settings
)
.
first
()
data
=
session
.
query
(
Settings
)
.
first
()
# type: Settings
self
.
config_calibre_dir
=
data
.
config_calibre_dir
self
.
config_port
=
data
.
config_port
self
.
config_calibre_web_title
=
data
.
config_calibre_web_title
...
...
@@ -326,6 +328,7 @@ class Config:
self
.
config_use_goodreads
=
data
.
config_use_goodreads
self
.
config_goodreads_api_key
=
data
.
config_goodreads_api_key
self
.
config_goodreads_api_secret
=
data
.
config_goodreads_api_secret
self
.
config_mature_content_tags
=
data
.
config_mature_content_tags
@
property
def
get_main_dir
(
self
):
...
...
@@ -371,6 +374,8 @@ class Config:
return
bool
((
self
.
config_default_role
is
not
None
)
and
(
self
.
config_default_role
&
ROLE_DELETE_BOOKS
==
ROLE_DELETE_BOOKS
))
def
mature_content_tags
(
self
):
return
self
.
config_mature_content_tags
.
split
(
","
)
def
get_Log_Level
(
self
):
ret_value
=
""
...
...
@@ -470,6 +475,11 @@ def migrate_Database():
'side_lang'
:
SIDEBAR_LANGUAGE
,
'side_series'
:
SIDEBAR_SERIES
,
'side_category'
:
SIDEBAR_CATEGORY
,
'side_hot'
:
SIDEBAR_HOT
,
'side_autor'
:
SIDEBAR_AUTHOR
,
'detail_random'
:
DETAIL_RANDOM
})
session
.
commit
()
try
:
session
.
query
(
exists
()
.
where
(
User
.
mature_content
))
.
scalar
()
except
exc
.
OperationalError
:
conn
=
engine
.
connect
()
conn
.
execute
(
"ALTER TABLE user ADD column `mature_content` INTEGER DEFAULT 1"
)
if
session
.
query
(
User
)
.
filter
(
User
.
role
.
op
(
'&'
)(
ROLE_ANONYMOUS
)
==
ROLE_ANONYMOUS
)
.
first
()
is
None
:
create_anonymous_user
()
try
:
...
...
@@ -484,6 +494,11 @@ def migrate_Database():
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_use_goodreads` INTEGER DEFAULT 0"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_goodreads_api_key` String DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_goodreads_api_secret` String DEFAULT ''"
)
try
:
session
.
query
(
exists
()
.
where
(
Settings
.
config_mature_content_tags
))
.
scalar
()
except
exc
.
OperationalError
:
conn
=
engine
.
connect
()
conn
.
execute
(
"ALTER TABLE Settings ADD column `config_mature_content_tags` String DEFAULT ''"
)
def
clean_database
():
# Remove expired remote login tokens
...
...
cps/web.py
View file @
b596734c
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