1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-24 18:47:23 +00:00

Handle stream output in logviewer

Add migration of global matrue content settings to user based settings
Fix Caliblur Theme (Publisherslist)
Allow/deny list/edit/add/delete of tags and custom columns
Colored table background for tags restriction
This commit is contained in:
Ozzieisaacs 2020-01-05 16:43:48 +01:00
parent 218e35e3aa
commit 661ed17d23
13 changed files with 289 additions and 130 deletions

View File

@ -183,8 +183,6 @@ def update_view_configuration():
config.config_default_role &= ~constants.ROLE_ANONYMOUS config.config_default_role &= ~constants.ROLE_ANONYMOUS
config.config_default_show = sum(int(k[5:]) for k in to_save if k.startswith('show_')) config.config_default_show = sum(int(k[5:]) for k in to_save if k.startswith('show_'))
'''if "Show_mature_content" in to_save:
config.config_default_show |= constants.MATURE_CONTENT'''
if "Show_detail_random" in to_save: if "Show_detail_random" in to_save:
config.config_default_show |= constants.DETAIL_RANDOM config.config_default_show |= constants.DETAIL_RANDOM
@ -259,26 +257,85 @@ def list_domain(allow):
def edit_restriction(type): def edit_restriction(type):
element = request.form.to_dict() element = request.form.to_dict()
if element['id'].startswith('a'): if element['id'].startswith('a'):
if type == 0: # Tags as template
elementlist = config.list_restricted_tags()
elementlist[id[1:]]=element['Element']
config.config_restricted_tags = ','.join(elementlist)
if type == 1: # CustomC
pass
if type == 2: # Tags per user
pass
if element['type'].startswith('d'):
if type == 0: # Tags as template if type == 0: # Tags as template
elementlist = config.list_allowed_tags() elementlist = config.list_allowed_tags()
elementlist[id[1:]]=element['Element'] elementlist[int(element['id'][1:])]=element['Element']
config.config_restricted_tags = ','.join(elementlist) config.config_allowed_tags = ','.join(elementlist)
config.save()
if type == 1: # CustomC if type == 1: # CustomC
elementlist = config.list_allowed_column_values()
elementlist[int(element['id'][1:])]=element['Element']
config.config_allowed_column_value = ','.join(elementlist)
config.save()
if type == 2: # Tags per user
usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
elementlist = usr.list_allowed_tags()
elementlist[int(element['id'][1:])]=element['Element']
usr.allowed_tags = ','.join(elementlist)
ub.session.commit()
if type == 3: # CColumn per user
usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
elementlist = usr.list_allowed_column_values()
elementlist[int(element['id'][1:])]=element['Element']
usr.allowed_column_value = ','.join(elementlist)
ub.session.commit()
if element['id'].startswith('d'):
if type == 0: # Tags as template
elementlist = config.list_restricted_tags()
elementlist[int(element['id'][1:])]=element['Element']
config.config_restricted_tags = ','.join(elementlist)
config.save()
if type == 1: # CustomC
elementlist = config.list_restricted_column_values()
elementlist[int(element['id'][1:])]=element['Element']
config.config_restricted_column_value = ','.join(elementlist)
config.save()
pass pass
if type == 2: # Tags per user if type == 2: # Tags per user
pass usr_id = os.path.split(request.referrer)[-1]
config.save() if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
elementlist = usr.list_restricted_tags()
elementlist[int(element['id'][1:])]=element['Element']
usr.restricted_tags = ','.join(elementlist)
ub.session.commit()
if type == 3: # CColumn per user
usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
elementlist = usr.list_restricted_column_values()
elementlist[int(element['id'][1:])]=element['Element']
usr.restricted_column_value = ','.join(elementlist)
ub.session.commit()
return "" return ""
def restriction_addition(element, list_func):
elementlist = list_func()
if elementlist == ['']:
elementlist = []
if not element['add_element'] in elementlist:
elementlist += [element['add_element']]
return ','.join(elementlist)
def restriction_deletion(element, list_func):
elementlist = list_func()
if element['Element'] in elementlist:
elementlist.remove(element['Element'])
return ','.join(elementlist)
@admi.route("/ajax/addrestriction/<int:type>", methods=['POST']) @admi.route("/ajax/addrestriction/<int:type>", methods=['POST'])
@login_required @login_required
@ -288,79 +345,131 @@ def add_restriction(type):
element = request.form.to_dict() element = request.form.to_dict()
if type == 0: # Tags as template if type == 0: # Tags as template
if 'submit_allow' in element: if 'submit_allow' in element:
elementlist = config.list_allowed_tags() config.config_allowed_tags = restriction_addition(element, config.list_allowed_tags)
if elementlist == ['']: config.save()
elementlist= [] elif 'submit_deny' in element:
if not element['add_element'] in elementlist: config.config_restricted_tags = restriction_addition(element, config.list_restricted_tags)
elementlist += [element['add_element']] config.save()
config.config_allowed_tags = ','.join(elementlist) if type == 1: # CCustom as template
elif 'submit_deny' in element: if 'submit_allow' in element:
elementlist = config.list_restricted_tags() config.config_allowed_column_value = restriction_addition(element, config.list_restricted_column_values)
if elementlist == ['']: config.save()
elementlist= [] elif 'submit_deny' in element:
if not element['add_element'] in elementlist: config.config_restricted_column_value = restriction_addition(element, config.list_allowed_column_values)
elementlist+=[element['add_element']]
config.config_restricted_tags = ','.join(elementlist)
config.save() config.save()
if type == 1: # CustomC
pass
if type == 2: # Tags per user if type == 2: # Tags per user
pass usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
if 'submit_allow' in element:
usr.allowed_tags = restriction_addition(element, usr.list_allowed_tags)
ub.session.commit()
elif 'submit_deny' in element:
usr.restricted_tags = restriction_addition(element, usr.list_restricted_tags)
ub.session.commit()
if type == 3: # CustomC per user
usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
if 'submit_allow' in element:
usr.allowed_column_value = restriction_addition(element, usr.list_allowed_column_values)
ub.session.commit()
elif 'submit_deny' in element:
usr.restricted_column_value = restriction_addition(element, usr.list_restricted_column_values)
ub.session.commit()
return "" return ""
@admi.route("/ajax/deleterestriction/<int:type>", methods=['POST']) @admi.route("/ajax/deleterestriction/<int:type>", methods=['POST'])
@login_required @login_required
@admin_required @admin_required
def delete_restriction(type): def delete_restriction(type):
element = request.form.to_dict() element = request.form.to_dict()
if int(element['type']) == 1:
if type == 0: # Tags as template if type == 0: # Tags as template
if element['id'].startswith('a'): if element['id'].startswith('a'):
elementlist = config.list_allowed_tags() config.config_allowed_tags = restriction_deletion(element, config.list_allowed_tags)
if element['Element'] in elementlist:
elementlist.remove(element['Element'])
config.config_allowed_tags = ','.join(elementlist)
elif element['id'].startswith('d'):
elementlist = config.list_restricted_tags()
if element['Element'] in elementlist:
elementlist.remove(element['Element'])
config.config_restricted_tags = ','.join(elementlist)
config.save() config.save()
if type == 1: # CustomC elif element['id'].startswith('d'):
pass config.config_restricted_tags = restriction_deletion(element, config.list_restricted_tags)
if type == 2: # Tags per user config.save()
pass elif type == 1: # CustomC as template
if int(element['type'])== 2: if element['id'].startswith('a'):
if type == 0: # Tags as template config.config_allowed_column_value = restriction_deletion(element, config.list_allowed_column_values)
elementlist = config.list_allowed_tags() config.save()
if not element['Element'] in elementlist: elif element['id'].startswith('d'):
elementlist+=element['Element'] config.config_restricted_column_value = restriction_deletion(element, config.list_restricted_column_values)
config.config_restricted_tags = ','.join(elementlist) config.save()
if type == 1: # CustomC elif type == 2: # Tags per user
pass usr_id = os.path.split(request.referrer)[-1]
if type == 2: # Tags per user if usr_id.isdigit() == True:
pass usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
if element['id'].startswith('a'):
usr.allowed_tags = restriction_deletion(element, usr.list_allowed_tags)
ub.session.commit()
elif element['id'].startswith('d'):
usr.restricted_tags = restriction_deletion(element, usr.list_restricted_tags)
ub.session.commit()
elif type == 3: # Columns per user
usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True: # select current user if admins are editing their own rights
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
else:
usr = current_user
if element['id'].startswith('a'):
usr.allowed_column_value = restriction_deletion(element, usr.list_allowed_column_values)
ub.session.commit()
elif element['id'].startswith('d'):
usr.restricted_column_value = restriction_deletion(element, usr.list_restricted_column_values)
ub.session.commit()
return "" return ""
#@admi.route("/ajax/listrestriction/<int:type>/<int:user_id>", defaults={'user_id': '0'})
@admi.route("/ajax/listrestriction/<int:type>") @admi.route("/ajax/listrestriction/<int:type>")
@login_required @login_required
@admin_required @admin_required
def list_restriction(type): def list_restriction(type):
if type == 0: # Tags as template if type == 0: # Tags as template
#for x, i in enumerate(config.list_restricted_tags()): restrict = [{'Element': x, 'type':'1', 'id': 'd'+str(i) }
# if x != '': for i,x in enumerate(config.list_restricted_tags()) if x != '' ]
# {'Element': x, 'type': '1', 'id': 'a' + str(i)} allow = [{'Element': x, 'type':'1', 'id': 'a'+str(i) }
restrict = [{'Element': x, 'type':'1', 'id': 'd'+str(i) } for i,x in enumerate(config.list_restricted_tags()) if x != '' ] for i,x in enumerate(config.list_allowed_tags()) if x != '']
allow = [{'Element': x, 'type':'1', 'id': 'a'+str(i) } for i,x in enumerate(config.list_allowed_tags()) if x != ''] json_dumps = restrict + allow
elif type == 1: # CustomC as template
restrict = [{'Element': x, 'type':'1', 'id': 'd'+str(i) }
for i,x in enumerate(config.list_restricted_column_values()) if x != '' ]
allow = [{'Element': x, 'type':'1', 'id': 'a'+str(i) }
for i,x in enumerate(config.list_allowed_column_values()) if x != '']
json_dumps = restrict + allow json_dumps = restrict + allow
elif type == 1: # CustomC
json_dumps = ""
elif type == 2: # Tags per user elif type == 2: # Tags per user
json_dumps = "" usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id == usr_id).first()
else: else:
json_dumps = "" usr = current_user
restrict = [{'Element': x, 'type':'2', 'id': 'd'+str(i) }
for i,x in enumerate(usr.list_restricted_tags()) if x != '' ]
allow = [{'Element': x, 'type':'2', 'id': 'a'+str(i) }
for i,x in enumerate(usr.list_allowed_tags()) if x != '']
json_dumps = restrict + allow
elif type == 3: # CustomC per user
usr_id = os.path.split(request.referrer)[-1]
if usr_id.isdigit() == True:
usr = ub.session.query(ub.User).filter(ub.User.id==usr_id).first()
else:
usr = current_user
restrict = [{'Element': x, 'type':'2', 'id': 'd'+str(i) }
for i,x in enumerate(usr.list_restricted_column_values()) if x != '' ]
allow = [{'Element': x, 'type':'2', 'id': 'a'+str(i) }
for i,x in enumerate(usr.list_allowed_column_values()) if x != '']
json_dumps = restrict + allow
else:
json_dumps=""
js = json.dumps(json_dumps) js = json.dumps(json_dumps)
response = make_response(js.replace("'", '"')) response = make_response(js.replace("'", '"'))
response.headers["Content-Type"] = "application/json; charset=utf-8" response.headers["Content-Type"] = "application/json; charset=utf-8"
@ -812,7 +921,9 @@ def view_logfile():
logfiles = {} logfiles = {}
logfiles[0] = logger.get_logfile(config.config_logfile) logfiles[0] = logger.get_logfile(config.config_logfile)
logfiles[1] = logger.get_accesslogfile(config.config_access_logfile) logfiles[1] = logger.get_accesslogfile(config.config_access_logfile)
return render_title_template("logviewer.html",title=_(u"Logfile viewer"), accesslog_enable=config.config_access_log, return render_title_template("logviewer.html",title=_(u"Logfile viewer"),
log_enable=bool(config.config_logfile != logger.LOG_TO_STDOUT),
accesslog_enable=config.config_access_log,
logfiles=logfiles, page="logfile") logfiles=logfiles, page="logfile")

View File

@ -25,7 +25,7 @@ import sys
from sqlalchemy import exc, Column, String, Integer, SmallInteger, Boolean from sqlalchemy import exc, Column, String, Integer, SmallInteger, Boolean
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from . import constants, cli, logger from . import constants, cli, logger, ub
log = logger.create() log = logger.create()
@ -57,7 +57,7 @@ class _Settings(_Base):
config_authors_max = Column(Integer, default=0) config_authors_max = Column(Integer, default=0)
config_read_column = Column(Integer, default=0) config_read_column = Column(Integer, default=0)
config_title_regex = Column(String, default=u'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+') config_title_regex = Column(String, default=u'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+')
# config_mature_content_tags = Column(String, default='') config_mature_content_tags = Column(String, default='')
config_theme = Column(Integer, default=0) config_theme = Column(Integer, default=0)
config_log_level = Column(SmallInteger, default=logger.DEFAULT_LOG_LEVEL) config_log_level = Column(SmallInteger, default=logger.DEFAULT_LOG_LEVEL)
@ -73,6 +73,7 @@ class _Settings(_Base):
config_default_role = Column(SmallInteger, default=0) config_default_role = Column(SmallInteger, default=0)
config_default_show = Column(SmallInteger, default=6143) config_default_show = Column(SmallInteger, default=6143)
config_columns_to_ignore = Column(String) config_columns_to_ignore = Column(String)
config_restricted_tags = Column(String, default="") config_restricted_tags = Column(String, default="")
config_allowed_tags = Column(String, default="") config_allowed_tags = Column(String, default="")
config_restricted_column = Column(SmallInteger, default=0) config_restricted_column = Column(SmallInteger, default=0)
@ -193,11 +194,11 @@ class _ConfigSQL(object):
return [t.strip() for t in mct] return [t.strip() for t in mct]
def list_restricted_column_values(self): def list_restricted_column_values(self):
mct = self.config_restricted_column_values().split(",") mct = self.config_restricted_column_value.split(",")
return [t.strip() for t in mct] return [t.strip() for t in mct]
def list_allowed_column_values(self): def list_allowed_column_values(self):
mct = self.config_allowed_column_values().split(",") mct = self.config_allowed_column_value.split(",")
return [t.strip() for t in mct] return [t.strip() for t in mct]
def get_log_level(self): def get_log_level(self):
@ -312,6 +313,7 @@ def _migrate_table(session, orm_class):
if changed: if changed:
session.commit() session.commit()
session.query
def autodetect_calibre_binary(): def autodetect_calibre_binary():
if sys.platform == "win32": if sys.platform == "win32":
@ -337,5 +339,12 @@ def load_configuration(session):
if not session.query(_Settings).count(): if not session.query(_Settings).count():
session.add(_Settings()) session.add(_Settings())
session.commit() session.commit()
conf = _ConfigSQL(session)
return _ConfigSQL(session) # Migrate from global restrictions to user based restrictions
if bool(conf.config_default_show & constants.MATURE_CONTENT) and conf.config_restricted_tags == "":
conf.config_restricted_tags = conf.config_mature_content_tags
conf.save()
session.query(ub.User).filter(ub.User.mature_content != True). \
update({"restricted_tags": conf.config_mature_content_tags}, synchronize_session=False)
session.commit()
return conf

View File

@ -315,9 +315,10 @@ def order_shelf(shelf_id):
ub.Shelf.id == shelf_id))).first() ub.Shelf.id == shelf_id))).first()
result = list() result = list()
if shelf: if shelf:
books_in_shelf2 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id) \ books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id) \
.order_by(ub.BookShelf.order.asc()).all() .order_by(ub.BookShelf.order.asc()).all()
books_list = [ b.book_id for b in books_in_shelf2] books_list = [ b.book_id for b in books_in_shelf]
# cover, title, series, name, all author names,
result = db.session.query(db.Books).filter(db.Books.id.in_(books_list)).filter(common_filters()).all() result = db.session.query(db.Books).filter(db.Books.id.in_(books_list)).filter(common_filters()).all()
return render_title_template('shelf_order.html', entries=result, return render_title_template('shelf_order.html', entries=result,
title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name), title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name),

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ html.http-error {
body{background:#f2f2f2}body h2{font-weight:normal;color:#444} body{background:#f2f2f2}body h2{font-weight:normal;color:#444}
body { margin-bottom: 40px;} body { margin-bottom: 40px;}
a{color: #45b29d}a:hover{color: #444;} a{color: #45b29d} /*a:hover{color: #444;}*/
.navigation .nav-head{text-transform:uppercase;color:#999;margin:20px 0}.navigation .nav-head:nth-child(1n+2){border-top:1px solid #ccc;padding-top:20px} .navigation .nav-head{text-transform:uppercase;color:#999;margin:20px 0}.navigation .nav-head:nth-child(1n+2){border-top:1px solid #ccc;padding-top:20px}
.navigation li a{color:#444;text-decoration:none;display:block;padding:10px}.navigation li a:hover{background:rgba(153,153,153,0.4);border-radius:5px} .navigation li a{color:#444;text-decoration:none;display:block;padding:10px}.navigation li a:hover{background:rgba(153,153,153,0.4);border-radius:5px}
.navigation li a span{margin-right:10px} .navigation li a span{margin-right:10px}
@ -78,6 +78,12 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
.spinner {margin:0 41%;} .spinner {margin:0 41%;}
.spinner2 {margin:0 41%;} .spinner2 {margin:0 41%;}
table .bg-dark-danger {background-color: #d9534f; color: #fff;}
table .bg-dark-danger a {color: #fff;}
table .bg-dark-danger:hover {background-color: #c9302c;}
table .bg-primary:hover {background-color: #1C5484;}
table .bg-primary a {color: #fff;}
.block-label {display: block;} .block-label {display: block;}
.fake-input {position: absolute; pointer-events: none; top: 0;} .fake-input {position: absolute; pointer-events: none; top: 0;}

View File

@ -17,7 +17,11 @@
// Upon loading load the logfile for the first option (event log) // Upon loading load the logfile for the first option (event log)
$(function() { $(function() {
init(0); if ($("#log_group input").length)
{
var element = $("#log_group input[type='radio']:checked").val();
init(element);
}
}); });
// After change the radio option load the corresponding log file // After change the radio option load the corresponding log file

View File

@ -95,28 +95,45 @@ $(function() {
}); });
$('#restrictModal').on('hidden.bs.modal', function () { $('#restrictModal').on('hidden.bs.modal', function () {
// Destroy table and remove hooks for buttons
$("#restrict-elements-table").unbind();
$('#restrict-elements-table').bootstrapTable('destroy'); $('#restrict-elements-table').bootstrapTable('destroy');
$("[id^=submit_]").unbind();
$('#h1').addClass('hidden');
$('#h2').addClass('hidden');
$('#h3').addClass('hidden');
$('#h4').addClass('hidden');
}); });
// $('#table').bootstrapTable('destroy');
function startTable(type){ function startTable(type){
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length-1].src;
var path = src.substring(0,src.lastIndexOf("/"));
$("#restrict-elements-table").bootstrapTable({ $("#restrict-elements-table").bootstrapTable({
formatNoMatches: function () { formatNoMatches: function () {
return ""; return "";
}, },
url:window.location.pathname + "/../../ajax/listrestriction/" + type, url: path + "/../../ajax/listrestriction/" + type,
rowStyle: function(row, index) {
console.log('Reihe :' + row + ' Index :'+ index);
if (row.id.charAt(0) == 'a') {
return {classes: 'bg-primary'}
}
else {
return {classes: 'bg-dark-danger'}
}
},
onClickCell: function (field, value, row, $element) { onClickCell: function (field, value, row, $element) {
// ...
if(field == 3){ if(field == 3){
console.log("element")
$.ajax ({ $.ajax ({
type: 'Post', type: 'Post',
data: 'id=' + row.id + '&type=' + row.type + "&Element=" + row.Element, data: 'id=' + row.id + '&type=' + row.type + "&Element=" + row.Element,
url: window.location.pathname + "/../../ajax/deleterestriction/" + type, url: path + "/../../ajax/deleterestriction/" + type,
async: true, async: true,
timeout: 900, timeout: 900,
success:function(data) { success:function(data) {
$.ajax({ $.ajax({
method:"get", method:"get",
url: window.location.pathname + "/../../ajax/listrestriction/"+type, url: path + "/../../ajax/listrestriction/"+type,
async: true, async: true,
timeout: 900, timeout: 900,
success:function(data) { success:function(data) {
@ -129,17 +146,28 @@ $(function() {
}, },
striped: false striped: false
}); });
$("[id^=submit_]").click(function(event) { $("#restrict-elements-table").removeClass('table-hover');
event.preventDefault(); $("#restrict-elements-table").on('editable-save.bs.table', function (e, field, row, old, $el) {
console.log($(this)[0].name) console.log("Hallo");
$.ajax({ $.ajax({
url: window.location.pathname + "/../../ajax/addrestriction/"+type, url: path + "/../../ajax/editrestriction/"+type,
type: 'Post',
data: row //$(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
});
});
$("[id^=submit_]").click(function(event) {
// event.stopPropagation();
// event.preventDefault();
$(this)[0].blur();
console.log($(this)[0].name);
$.ajax({
url: path + "/../../ajax/addrestriction/"+type,
type: 'Post', type: 'Post',
data: $(this).closest("form").serialize() + "&" + $(this)[0].name + "=", data: $(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
success: function () { success: function () {
$.ajax ({ $.ajax ({
method:"get", method:"get",
url: window.location.pathname + "/../../ajax/listrestriction/"+type, url: path + "/../../ajax/listrestriction/"+type,
async: true, async: true,
timeout: 900, timeout: 900,
success:function(data) { success:function(data) {
@ -154,12 +182,27 @@ $(function() {
$('#get_column_values').on('click',function() $('#get_column_values').on('click',function()
{ {
startTable(1); startTable(1);
$('#h2').removeClass('hidden');
}); });
$('#get_tags').on('click',function() $('#get_tags').on('click',function()
{ {
startTable(0); startTable(0);
$('#h1').removeClass('hidden');
}); });
$('#get_user_column_values').on('click',function()
{
startTable(3);
$('#h4').removeClass('hidden');
});
$('#get_user_tags').on('click',function()
{
startTable(2);
$(this)[0].blur();
$('#h3').removeClass('hidden');
});
}); });
/* Function for deleting domain restrictions */ /* Function for deleting domain restrictions */

View File

@ -115,17 +115,6 @@
<input type="checkbox" name="edit_shelf_role" id="edit_shelf_role" {% if conf.role_edit_shelfs() %}checked{% endif %}> <input type="checkbox" name="edit_shelf_role" id="edit_shelf_role" {% if conf.role_edit_shelfs() %}checked{% endif %}>
<label for="edit_shelf_role">{{_('Allow Editing Public Shelfs')}}</label> <label for="edit_shelf_role">{{_('Allow Editing Public Shelfs')}}</label>
</div> </div>
<!--div class="form-group">
<label for="config_restricted_tags">{{_('Restrict Tags')}}</label>
<input type="text" class="form-control" name="config_restricted_tags" id="config_restricted_tags" value="{{ conf.config_restricted_tags if conf.config_restricted_tags != None }}" autocomplete="off">
</div-->
<a href="#" id="get_tags" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add allowed/denied Tags')}}</a>
<a href="#" id="get_column_values" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add allowed/denied custom column values')}}</a>
<!--div class="form-group">
<label for="config_restricted_column_value">{{_('Restricted Column Content')}}</label>
<input type="text" class="form-control" name="config_restricted_column_value" id="config_restricted_column_value" value="{{ conf.config_restricted_column_value if conf.config_restricted_column_value != None }}" autocomplete="off">
</div-->
</div> </div>
</div> </div>
</div> </div>
@ -152,6 +141,8 @@
<input type="checkbox" name="Show_detail_random" id="Show_detail_random" {% if conf.show_detail_random() %}checked{% endif %}> <input type="checkbox" name="Show_detail_random" id="Show_detail_random" {% if conf.show_detail_random() %}checked{% endif %}>
<label for="Show_detail_random">{{_('Show random books in detail view')}}</label> <label for="Show_detail_random">{{_('Show random books in detail view')}}</label>
</div> </div>
<a href="#" id="get_tags" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add allowed/denied Tags')}}</a>
<a href="#" id="get_column_values" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add allowed/denied custom column values')}}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,6 +12,7 @@
<link rel="apple-touch-icon" sizes="140x140" href="{{ url_for('static', filename='favicon.ico') }}"> <link rel="apple-touch-icon" sizes="140x140" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link href="{{ url_for('static', filename='css/libs/bootstrap.min.css') }}" rel="stylesheet" media="screen"> <link href="{{ url_for('static', filename='css/libs/bootstrap.min.css') }}" rel="stylesheet" media="screen">
{% block header %}{% endblock %}
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" media="screen"> <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" media="screen">
<link href="{{ url_for('static', filename='css/upload.css') }}" rel="stylesheet" media="screen"> <link href="{{ url_for('static', filename='css/upload.css') }}" rel="stylesheet" media="screen">
{% if g.current_theme == 1 %} {% if g.current_theme == 1 %}
@ -23,8 +24,6 @@
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]--> <![endif]-->
{% block header %}{% endblock %}
</head> </head>
<body class="{{ page }}" data-text="{{_('Home')}}" data-textback="{{_('Back')}}"> <body class="{{ page }}" data-text="{{_('Home')}}" data-textback="{{_('Back')}}">
<!-- Static navbar --> <!-- Static navbar -->

View File

@ -1,11 +1,15 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block body %} {% block body %}
<div id="log_group" class="inputs"> <div id="log_group" class="inputs">
{% if log_enable %}
<div><input type="radio" name="log_radio" id="log1" value="0" checked> <div><input type="radio" name="log_radio" id="log1" value="0" checked>
<label for="log0">{{_('Show Calibre-Web log')}}</label> {{logfiles[0]}}</div> <label for="log1">{{_('Show Calibre-Web log: ')}}</label>{{logfiles[0]}}</div>
{% else %}
<div><label for="log1">{{_('Calibre-Web log: ')}}</label> {{_("Stream output, can't be displayed")}}</div>
{% endif %}
{% if accesslog_enable %} {% if accesslog_enable %}
<div><input type="radio" name="log_radio" id="log0" value="1"> <div><input type="radio" name="log_radio" id="log0" value="1" {% if not log_enable %}checked{% endif %}>
<label for="log1">{{_('Show access log')}}</label> {{logfiles[1]}}</div> <label for="log0">{{_('Show access log: ')}}</label>{{logfiles[1]}}</div>
{% endif %} {% endif %}
</div> </div>
<div id="renderer" class="log"></div> <div id="renderer" class="log"></div>

View File

@ -3,13 +3,16 @@
<div class="modal-dialog modal-lg" role="document"> <div class="modal-dialog modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" id="metaModalLabel">{{_('Select allowed/restricted Tags')}}</h4> <h4 class="modal-title hidden" id="h1">{{_('Select allowed/restricted Tags')}}</h4>
<h4 class="modal-title hidden" id="h2">{{_('Select allowed/restricted Custom Column values')}}</h4>
<h4 class="modal-title hidden" id="h3">{{_('Select allowed/restricted Tags of user')}}</h4>
<h4 class="modal-title hidden" id="h4">{{_('Select allowed/restricted Custom Column values of user')}}</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<table class="table table-no-bordered" id="restrict-elements-table" data-id-field="id" data-show-header="false" data-editable-mode="inline"> <table class="table table-no-bordered" id="restrict-elements-table" data-id-field="id" data-show-header="false" data-editable-mode="inline">
<thead> <thead>
<tr> <tr>
<th data-field="Element" id="Element" data-editable-type="text" data-editable-url="{{ url_for('admin.edit_restriction', type = 0)}}" data-editable="true" data-editable-title="{{_('Enter Tag')}}"></th> <th data-field="Element" id="Element" data-editable-type="text" data-editable="true" data-editable-title="{{_('Enter Tag')}}"></th>
<th data-field="type" id="type" data-visible="false"></th> <th data-field="type" id="type" data-visible="false"></th>
<th data-field="id" id="id" data-visible="false"></th> <th data-field="id" id="id" data-visible="false"></th>
<th data-align="right" data-formatter="RestrictionActions"></th> <th data-align="right" data-formatter="RestrictionActions"></th>

View File

@ -31,17 +31,6 @@
<label for="kobo_user_key">{{_('KoboStore UserKey')}}</label> <label for="kobo_user_key">{{_('KoboStore UserKey')}}</label>
<input type="password" class="form-control" name="kobo_user_key" id="kobo_user_key" value="" autocomplete="off"> <input type="password" class="form-control" name="kobo_user_key" id="kobo_user_key" value="" autocomplete="off">
</div> </div>
{% if ( g.user and g.user.role_admin() ) %}
<div class="form-group">
<label for="restricted_tags">{{_('Restricted Tags')}}</label>
<input type="text" class="form-control" name="restricted_tags" id="restricted_tags" value="{{ content.restricted_tags if content.restricted_tags != None }}" autocomplete="off">
</div>
<div class="form-group">
<label for="restricted_column_value">{{_('Restricted Column Content')}}</label>
<input type="text" class="form-control" name="restricted_column_value" id="restricted_column_value" value="{{ content.restricted_column_value if content.restricted_column_value != None }}" autocomplete="off">
</div>
{% endif %}
<label for="locale">{{_('Language')}}</label> <label for="locale">{{_('Language')}}</label>
<select name="locale" id="locale" class="form-control"> <select name="locale" id="locale" class="form-control">
{% for translation in translations %} {% for translation in translations %}
@ -84,6 +73,10 @@
<input type="checkbox" name="Show_detail_random" id="Show_detail_random" {% if content.show_detail_random() %}checked{% endif %}> <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> <label for="Show_detail_random">{{_('Show random books in detail view')}}</label>
</div> </div>
{% if ( g.user and g.user.role_admin() ) %}
<a href="#" id="get_user_tags" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add allowed/denied Tags')}}</a>
<a href="#" id="get_user_column_values" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add allowed/denied custom column values')}}</a>
{% endif %}
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
{% if g.user and g.user.role_admin() and not profile %} {% if g.user and g.user.role_admin() and not profile %}
@ -93,10 +86,6 @@
<label for="admin_role">{{_('Admin user')}}</label> <label for="admin_role">{{_('Admin user')}}</label>
</div> </div>
{% endif %} {% endif %}
<!--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"> <div class="form-group">
<input type="checkbox" name="download_role" id="download_role" {% if content.role_download() %}checked{% endif %}> <input type="checkbox" name="download_role" id="download_role" {% if content.role_download() %}checked{% endif %}>
<label for="download_role">{{_('Allow Downloads')}}</label> <label for="download_role">{{_('Allow Downloads')}}</label>

View File

@ -166,11 +166,11 @@ class UserBase:
return [t.strip() for t in mct] return [t.strip() for t in mct]
def list_restricted_column_values(self): def list_restricted_column_values(self):
mct = self.restricted_column_values().split(",") mct = self.restricted_column_value.split(",")
return [t.strip() for t in mct] return [t.strip() for t in mct]
def list_allowed_column_values(self): def list_allowed_column_values(self):
mct = self.allowed_column_values().split(",") mct = self.allowed_column_value.split(",")
return [t.strip() for t in mct] return [t.strip() for t in mct]
def __repr__(self): def __repr__(self):
@ -194,7 +194,7 @@ class User(UserBase, Base):
locale = Column(String(2), default="en") locale = Column(String(2), default="en")
sidebar_view = Column(Integer, default=1) sidebar_view = Column(Integer, default=1)
default_language = Column(String(3), default="all") default_language = Column(String(3), default="all")
# mature_content = Column(Boolean, default=True) mature_content = Column(Boolean, default=True)
restricted_tags = Column(String, default="") restricted_tags = Column(String, default="")
allowed_tags = Column(String, default="") allowed_tags = Column(String, default="")
restricted_column_value = Column(String, default="") restricted_column_value = Column(String, default="")
@ -232,11 +232,10 @@ class Anonymous(AnonymousUserMixin, UserBase):
self.sidebar_view = data.sidebar_view self.sidebar_view = data.sidebar_view
self.default_language = data.default_language self.default_language = data.default_language
self.locale = data.locale self.locale = data.locale
# self.mature_content = data.mature_content self.mature_content = data.mature_content
self.kindle_mail = data.kindle_mail self.kindle_mail = data.kindle_mail
self.restricted_tags = data.restricted_tags self.restricted_tags = data.restricted_tags
self.allowed_tags = data.allowed_tags self.allowed_tags = data.allowed_tags
# self.restricted_column = data.restricted_column
self.restricted_column_value = data.restricted_column_value self.restricted_column_value = data.restricted_column_value
self.allowed_column_value = data.allowed_column_value self.allowed_column_value = data.allowed_column_value