Fix for #448
This commit is contained in:
parent
ea6a957c05
commit
f6ece5fe72
3 changed files with 14 additions and 2 deletions
|
@ -203,6 +203,10 @@
|
|||
<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 class="form-group">
|
||||
<input type="checkbox" name="show_mature_content" id="show_mature_content" {% if content.show_mature_content() %}checked{% endif %}>
|
||||
<label for="show_mature_content">{{_('Show mature content')}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
|
|
|
@ -41,7 +41,7 @@ SIDEBAR_BEST_RATED = 128
|
|||
SIDEBAR_READ_AND_UNREAD = 256
|
||||
SIDEBAR_RECENT = 512
|
||||
SIDEBAR_SORTED = 1024
|
||||
|
||||
MATURE_CONTENT = 2048
|
||||
|
||||
DEFAULT_PASS = "admin123"
|
||||
DEFAULT_PORT = int(os.environ.get("CALIBRE_PORT", 8083))
|
||||
|
@ -458,6 +458,10 @@ class Config:
|
|||
return bool((self.config_default_show is not None) and
|
||||
(self.config_default_show & SIDEBAR_SORTED == SIDEBAR_SORTED))
|
||||
|
||||
def show_mature_content(self):
|
||||
return bool((self.config_default_show is not None) and
|
||||
(self.config_default_show & MATURE_CONTENT == MATURE_CONTENT))
|
||||
|
||||
def mature_content_tags(self):
|
||||
if sys.version_info > (3, 0): # Python3 str, Python2 unicode
|
||||
lstrip = str.lstrip
|
||||
|
@ -665,7 +669,7 @@ def create_admin_user():
|
|||
user.role = ROLE_USER + ROLE_ADMIN + ROLE_DOWNLOAD + ROLE_UPLOAD + ROLE_EDIT + ROLE_DELETE_BOOKS + ROLE_PASSWD
|
||||
user.sidebar_view = DETAIL_RANDOM + SIDEBAR_LANGUAGE + SIDEBAR_SERIES + SIDEBAR_CATEGORY + SIDEBAR_HOT + \
|
||||
SIDEBAR_RANDOM + SIDEBAR_AUTHOR + SIDEBAR_BEST_RATED + SIDEBAR_READ_AND_UNREAD + SIDEBAR_RECENT + \
|
||||
SIDEBAR_SORTED
|
||||
SIDEBAR_SORTED + MATURE_CONTENT
|
||||
|
||||
user.password = generate_password_hash(DEFAULT_PASS)
|
||||
|
||||
|
|
|
@ -2601,6 +2601,9 @@ def configuration_helper(origin):
|
|||
content.config_default_show = content.config_default_show + ub.SIDEBAR_RECENT
|
||||
if "show_sorted" in to_save:
|
||||
content.config_default_show = content.config_default_show + ub.SIDEBAR_SORTED
|
||||
if "show_mature_content" in to_save:
|
||||
content.config_default_show = content.config_default_show + ub.MATURE_CONTENT
|
||||
|
||||
if content.config_logfile != to_save["config_logfile"]:
|
||||
# check valid path, only path or file
|
||||
if os.path.dirname(to_save["config_logfile"]):
|
||||
|
@ -2724,6 +2727,7 @@ def new_user():
|
|||
else:
|
||||
content.role = config.config_default_role
|
||||
content.sidebar_view = config.config_default_show
|
||||
content.mature_content = bool(config.config_default_show & ub.MATURE_CONTENT)
|
||||
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
||||
languages=languages, title=_(u"Add new user"))
|
||||
|
||||
|
|
Loading…
Reference in a new issue