Commit 661ed17d authored by Ozzieisaacs's avatar Ozzieisaacs

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
parent 218e35e3
This diff is collapsed.
......@@ -25,7 +25,7 @@ import sys
from sqlalchemy import exc, Column, String, Integer, SmallInteger, Boolean
from sqlalchemy.ext.declarative import declarative_base
from . import constants, cli, logger
from . import constants, cli, logger, ub
log = logger.create()
......@@ -57,7 +57,7 @@ class _Settings(_Base):
config_authors_max = 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_mature_content_tags = Column(String, default='')
config_mature_content_tags = Column(String, default='')
config_theme = Column(Integer, default=0)
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_show = Column(SmallInteger, default=6143)
config_columns_to_ignore = Column(String)
config_restricted_tags = Column(String, default="")
config_allowed_tags = Column(String, default="")
config_restricted_column = Column(SmallInteger, default=0)
......@@ -193,11 +194,11 @@ class _ConfigSQL(object):
return [t.strip() for t in mct]
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]
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]
def get_log_level(self):
......@@ -312,6 +313,7 @@ def _migrate_table(session, orm_class):
if changed:
session.commit()
session.query
def autodetect_calibre_binary():
if sys.platform == "win32":
......@@ -337,5 +339,12 @@ def load_configuration(session):
if not session.query(_Settings).count():
session.add(_Settings())
session.commit()
return _ConfigSQL(session)
conf = _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
......@@ -315,9 +315,10 @@ def order_shelf(shelf_id):
ub.Shelf.id == shelf_id))).first()
result = list()
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()
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()
return render_title_template('shelf_order.html', entries=result,
title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name),
......
This diff is collapsed.
......@@ -26,7 +26,7 @@ html.http-error {
body{background:#f2f2f2}body h2{font-weight:normal;color:#444}
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 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}
......@@ -78,6 +78,12 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
.spinner {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;}
.fake-input {position: absolute; pointer-events: none; top: 0;}
......
......@@ -17,7 +17,11 @@
// Upon loading load the logfile for the first option (event log)
$(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
......
......@@ -95,51 +95,79 @@ $(function() {
});
$('#restrictModal').on('hidden.bs.modal', function () {
// Destroy table and remove hooks for buttons
$("#restrict-elements-table").unbind();
$('#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){
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length-1].src;
var path = src.substring(0,src.lastIndexOf("/"));
$("#restrict-elements-table").bootstrapTable({
formatNoMatches: function () {
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) {
// ...
if(field == 3){
console.log("element")
$.ajax ({
type: 'Post',
data: 'id=' + row.id + '&type=' + row.type + "&Element=" + row.Element,
url: window.location.pathname + "/../../ajax/deleterestriction/" + type,
url: path + "/../../ajax/deleterestriction/" + type,
async: true,
timeout: 900,
success:function(data) {
$.ajax({
method:"get",
url: window.location.pathname + "/../../ajax/listrestriction/"+type,
url: path + "/../../ajax/listrestriction/"+type,
async: true,
timeout: 900,
success:function(data) {
$("#restrict-elements-table").bootstrapTable("load", data);
}
});
}
});
}
});
}
},
striped: false
});
$("#restrict-elements-table").removeClass('table-hover');
$("#restrict-elements-table").on('editable-save.bs.table', function (e, field, row, old, $el) {
console.log("Hallo");
$.ajax({
url: path + "/../../ajax/editrestriction/"+type,
type: 'Post',
data: row //$(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
});
});
$("[id^=submit_]").click(function(event) {
event.preventDefault();
console.log($(this)[0].name)
// event.stopPropagation();
// event.preventDefault();
$(this)[0].blur();
console.log($(this)[0].name);
$.ajax({
url: window.location.pathname + "/../../ajax/addrestriction/"+type,
url: path + "/../../ajax/addrestriction/"+type,
type: 'Post',
data: $(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
success: function () {
$.ajax ({
method:"get",
url: window.location.pathname + "/../../ajax/listrestriction/"+type,
url: path + "/../../ajax/listrestriction/"+type,
async: true,
timeout: 900,
success:function(data) {
......@@ -154,12 +182,27 @@ $(function() {
$('#get_column_values').on('click',function()
{
startTable(1);
$('#h2').removeClass('hidden');
});
$('#get_tags').on('click',function()
{
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 */
......
......@@ -115,17 +115,6 @@
<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>
</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>
......@@ -152,6 +141,8 @@
<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>
</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>
......
......@@ -12,6 +12,7 @@
<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 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/upload.css') }}" rel="stylesheet" media="screen">
{% 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/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
{% block header %}{% endblock %}
</head>
<body class="{{ page }}" data-text="{{_('Home')}}" data-textback="{{_('Back')}}">
<!-- Static navbar -->
......
{% extends "layout.html" %}
{% block body %}
<div id="log_group" class="inputs">
{% if log_enable %}
<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 %}
<div><input type="radio" name="log_radio" id="log0" value="1">
<label for="log1">{{_('Show access log')}}</label> {{logfiles[1]}}</div>
<div><input type="radio" name="log_radio" id="log0" value="1" {% if not log_enable %}checked{% endif %}>
<label for="log0">{{_('Show access log: ')}}</label>{{logfiles[1]}}</div>
{% endif %}
</div>
<div id="renderer" class="log"></div>
......
......@@ -3,13 +3,16 @@
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<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 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">
<thead>
<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="id" id="id" data-visible="false"></th>
<th data-align="right" data-formatter="RestrictionActions"></th>
......
......@@ -31,17 +31,6 @@
<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">
</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>
<select name="locale" id="locale" class="form-control">
{% 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 %}>
<label for="Show_detail_random">{{_('Show random books in detail view')}}</label>
</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 class="col-sm-6">
{% if g.user and g.user.role_admin() and not profile %}
......@@ -93,10 +86,6 @@
<label for="admin_role">{{_('Admin user')}}</label>
</div>
{% 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">
<input type="checkbox" name="download_role" id="download_role" {% if content.role_download() %}checked{% endif %}>
<label for="download_role">{{_('Allow Downloads')}}</label>
......
......@@ -166,11 +166,11 @@ class UserBase:
return [t.strip() for t in mct]
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]
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]
def __repr__(self):
......@@ -194,7 +194,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)
mature_content = Column(Boolean, default=True)
restricted_tags = Column(String, default="")
allowed_tags = Column(String, default="")
restricted_column_value = Column(String, default="")
......@@ -232,11 +232,10 @@ class Anonymous(AnonymousUserMixin, UserBase):
self.sidebar_view = data.sidebar_view
self.default_language = data.default_language
self.locale = data.locale
# self.mature_content = data.mature_content
self.mature_content = data.mature_content
self.kindle_mail = data.kindle_mail
self.restricted_tags = data.restricted_tags
self.allowed_tags = data.allowed_tags
# self.restricted_column = data.restricted_column
self.restricted_column_value = data.restricted_column_value
self.allowed_column_value = data.allowed_column_value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment