1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 01:50:31 +00:00

user list column value and tags editor (#1938)

Bugfixes for massedit in user list (#1938)
Changed no. of debug messages
This commit is contained in:
Ozzie Isaacs 2021-04-25 10:42:41 +02:00
parent 450ee43677
commit 97e4707f72
6 changed files with 276 additions and 149 deletions

View File

@ -225,11 +225,23 @@ def edit_user_table():
languages = calibre_db.speaking_language() languages = calibre_db.speaking_language()
translations = babel.list_translations() + [LC('en')] translations = babel.list_translations() + [LC('en')]
allUser = ub.session.query(ub.User) allUser = ub.session.query(ub.User)
tags = calibre_db.session.query(db.Tags)\
.join(db.books_tags_link)\
.join(db.Books)\
.filter(calibre_db.common_filters()) \
.group_by(text('books_tags_link.tag'))\
.order_by(db.Tags.name).all()
if config.config_restricted_column:
custom_values = calibre_db.session.query(db.cc_classes[config.config_restricted_column]).all()
else:
custom_values = []
if not config.config_anonbrowse: if not config.config_anonbrowse:
allUser = allUser.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) != constants.ROLE_ANONYMOUS) allUser = allUser.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) != constants.ROLE_ANONYMOUS)
return render_title_template("user_table.html", return render_title_template("user_table.html",
users=allUser.all(), users=allUser.all(),
tags=tags,
custom_values=custom_values,
translations=translations, translations=translations,
languages=languages, languages=languages,
visiblility=visibility, visiblility=visibility,
@ -238,6 +250,7 @@ def edit_user_table():
title=_(u"Edit Users"), title=_(u"Edit Users"),
page="usertable") page="usertable")
@admi.route("/ajax/listusers") @admi.route("/ajax/listusers")
@login_required @login_required
@admin_required @admin_required
@ -332,7 +345,7 @@ def table_get_locale():
def table_get_default_lang(): def table_get_default_lang():
languages = calibre_db.speaking_language() languages = calibre_db.speaking_language()
ret = list() ret = list()
ret.append({'value':'all','text':_('Show All')}) ret.append({'value': 'all', 'text': _('Show All')})
for lang in languages: for lang in languages:
ret.append({'value': lang.lang_code, 'text': lang.name}) ret.append({'value': lang.lang_code, 'text': lang.name})
return json.dumps(ret) return json.dumps(ret)
@ -358,56 +371,55 @@ def edit_list_user(param):
vals['field_index'] = vals['field_index'][0] vals['field_index'] = vals['field_index'][0]
if 'value' in vals: if 'value' in vals:
vals['value'] = vals['value'][0] vals['value'] = vals['value'][0]
else: elif not ('value[]' in vals):
return "" return ""
for user in users: for user in users:
try: try:
vals['value'] = vals['value'].strip() if param in ['denied_tags', 'allowed_tags', 'allowed_column_value', 'denied_column_value']:
if param == 'name': if 'value[]' in vals:
if user.name == "Guest": setattr(user, param, prepare_tags(user, vals['action'][0], param, vals['value[]']))
raise Exception(_("Guest Name can't be changed"))
user.name = check_username(vals['value'])
elif param =='email':
user.email = check_email(vals['value'])
elif param == 'kindle_mail':
user.kindle_mail = valid_email(vals['value']) if vals['value'] else ""
elif param.endswith('role'):
if user.name == "Guest" and int(vals['field_index']) in \
[constants.ROLE_ADMIN, constants.ROLE_PASSWD, constants.ROLE_EDIT_SHELFS]:
raise Exception(_("Guest can't have this role"))
if vals['value'] == 'true':
user.role |= int(vals['field_index'])
else: else:
if int(vals['field_index']) == constants.ROLE_ADMIN: setattr(user, param, vals['value'].strip())
if not ub.session.query(ub.User).\ else:
filter(ub.User.role.op('&')(constants.ROLE_ADMIN) == constants.ROLE_ADMIN, vals['value'] = vals['value'].strip()
ub.User.id != user.id).count(): if param == 'name':
return Response(json.dumps([{'type': "danger", if user.name == "Guest":
'message':_(u"No admin user remaining, can't remove admin role", raise Exception(_("Guest Name can't be changed"))
nick=user.name)}]), mimetype='application/json') user.name = check_username(vals['value'])
user.role &= ~int(vals['field_index']) elif param =='email':
elif param.startswith('sidebar'): user.email = check_email(vals['value'])
if user.name == "Guest" and int(vals['field_index']) == constants.SIDEBAR_READ_AND_UNREAD: elif param == 'kindle_mail':
raise Exception(_("Guest can't have this view")) user.kindle_mail = valid_email(vals['value']) if vals['value'] else ""
if vals['value'] == 'true': elif param.endswith('role'):
user.sidebar_view |= int(vals['field_index']) if user.name == "Guest" and int(vals['field_index']) in \
else: [constants.ROLE_ADMIN, constants.ROLE_PASSWD, constants.ROLE_EDIT_SHELFS]:
user.sidebar_view &= ~int(vals['field_index']) raise Exception(_("Guest can't have this role"))
elif param == 'denied_tags': if vals['value'] == 'true':
user.denied_tags = vals['value'] user.role |= int(vals['field_index'])
elif param == 'allowed_tags': else:
user.allowed_tags = vals['value'] if int(vals['field_index']) == constants.ROLE_ADMIN:
elif param == 'allowed_column_value': if not ub.session.query(ub.User).\
user.allowed_column_value = vals['value'] filter(ub.User.role.op('&')(constants.ROLE_ADMIN) == constants.ROLE_ADMIN,
elif param == 'denied_column_value': ub.User.id != user.id).count():
user.denied_column_value = vals['value'] return Response(json.dumps([{'type': "danger",
elif param == 'locale': 'message':_(u"No admin user remaining, can't remove admin role",
if user.name == "Guest": nick=user.name)}]), mimetype='application/json')
raise Exception(_("Guest's Locale is determined automatically and can't be set")) user.role &= ~int(vals['field_index'])
user.locale = vals['value'] elif param.startswith('sidebar'):
elif param == 'default_language': if user.name == "Guest" and int(vals['field_index']) == constants.SIDEBAR_READ_AND_UNREAD:
user.default_language = vals['value'] raise Exception(_("Guest can't have this view"))
if vals['value'] == 'true':
user.sidebar_view |= int(vals['field_index'])
else:
user.sidebar_view &= ~int(vals['field_index'])
elif param == 'locale':
if user.name == "Guest":
raise Exception(_("Guest's Locale is determined automatically and can't be set"))
user.locale = vals['value']
elif param == 'default_language':
user.default_language = vals['value']
except Exception as ex: except Exception as ex:
log.debug_or_exception(ex)
return str(ex), 400 return str(ex), 400
ub.session_commit() ub.session_commit()
return "" return ""
@ -483,6 +495,8 @@ def load_dialogtexts(element_id):
texts["main"] = _('Are you sure you want to change visible book languages for selected user(s)?') texts["main"] = _('Are you sure you want to change visible book languages for selected user(s)?')
elif element_id == "role": elif element_id == "role":
texts["main"] = _('Are you sure you want to change the selected role for the selected user(s)?') texts["main"] = _('Are you sure you want to change the selected role for the selected user(s)?')
elif element_id == "restrictions":
texts["main"] = _('Are you sure you want to change the selected restrictions for the selected user(s)?')
elif element_id == "sidebar_view": elif element_id == "sidebar_view":
texts["main"] = _('Are you sure you want to change the selected visibility restrictions for the selected user(s)?') texts["main"] = _('Are you sure you want to change the selected visibility restrictions for the selected user(s)?')
return json.dumps(texts) return json.dumps(texts)
@ -629,6 +643,22 @@ def restriction_deletion(element, list_func):
return ','.join(elementlist) return ','.join(elementlist)
def prepare_tags(user, action, tags_name, id_list):
if "tags" in tags_name:
tags = calibre_db.session.query(db.Tags).filter(db.Tags.id.in_(id_list)).all()
new_tags_list = [x.name for x in tags]
else:
tags = calibre_db.session.query(db.cc_classes[config.config_restricted_column])\
.filter(db.cc_classes[config.config_restricted_column].id.in_(id_list)).all()
new_tags_list = [x.value for x in tags]
saved_tags_list = user.__dict__[tags_name].split(",") if len(user.__dict__[tags_name]) else []
if action == "remove":
saved_tags_list = [x for x in saved_tags_list if x not in new_tags_list]
else:
saved_tags_list.extend(x for x in new_tags_list if x not in saved_tags_list)
return ",".join(saved_tags_list)
@admi.route("/ajax/addrestriction/<int:res_type>", defaults={"user_id": 0}, methods=['POST']) @admi.route("/ajax/addrestriction/<int:res_type>", defaults={"user_id": 0}, methods=['POST'])
@admi.route("/ajax/addrestriction/<int:res_type>/<int:user_id>", methods=['POST']) @admi.route("/ajax/addrestriction/<int:res_type>/<int:user_id>", methods=['POST'])
@login_required @login_required

View File

@ -61,6 +61,7 @@ def get_user_info(credentials):
return user_info.get('email', "") return user_info.get('email', "")
def send_messsage(token, msg): def send_messsage(token, msg):
log.debug("Start sending email via Gmail")
creds = Credentials( creds = Credentials(
token=token['token'], token=token['token'],
refresh_token=token['refresh_token'], refresh_token=token['refresh_token'],
@ -79,3 +80,4 @@ def send_messsage(token, msg):
body = {'raw': raw} body = {'raw': raw}
(service.users().messages().send(userId='me', body=body).execute()) (service.users().messages().send(userId='me', body=body).execute())
log.debug("Email send successfully via Gmail")

View File

@ -15,6 +15,10 @@ body {
overflow: hidden; overflow: hidden;
} }
.myselect {
overflow: visible !important;
}
#main { #main {
position: absolute; position: absolute;
width: 100%; width: 100%;

View File

@ -21,7 +21,6 @@
var selections = []; var selections = [];
$(function() { $(function() {
$("#books-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", $("#books-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table",
function (e, rowsAfter, rowsBefore) { function (e, rowsAfter, rowsBefore) {
var rows = rowsAfter; var rows = rowsAfter;
@ -453,27 +452,11 @@ $(function() {
}); });
}, },
onPostHeader () { onPostHeader () {
deactivateHeaderButtons(); move_header_elements();
}, },
onLoadSuccess: function () { onLoadSuccess: function () {
loadSuccess(); loadSuccess();
var element = $(".header_select"); move_header_elements();
element.each(function() {
var item = $(this).parent();
var parent = item.parent().parent();
if (parent.prop('nodeName') === "TH") {
item.prependTo(parent);
}
});
var element = $(".form-check");
element.each(function() {
var item = $(this).parent();
var parent = item.parent().parent();
if (parent.prop('nodeName') === "TH") {
item.prependTo(parent);
}
});
}, },
onColumnSwitch: function () { onColumnSwitch: function () {
var visible = $("#user-table").bootstrapTable("getVisibleColumns"); var visible = $("#user-table").bootstrapTable("getVisibleColumns");
@ -493,56 +476,10 @@ $(function() {
url: window.location.pathname + "/../../ajax/user_table_settings", url: window.location.pathname + "/../../ajax/user_table_settings",
data: "{" + st + "}", data: "{" + st + "}",
}); });
handle_header_buttons();
}, },
}); });
$("#user_delete_selection").click(function() {
$("#user-table").bootstrapTable("uncheckAll");
});
$("#select_locale").on("change",function() {
selectHeader(this, "locale");
});
$("#select_default_language").on("change",function() {
selectHeader(this, "default_language");
});
$(".check_head").on("change",function() {
var val = $(this).val() === "on";
var name = $(this).data("name");
var data = $(this).data("val");
checkboxHeader(val, name, data);
});
$(".button_head").on("click",function() {
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
confirmDialog(
"btndeluser",
"GeneralDeleteModal",
0,
function() {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/deleteuser",
data: {"userid": result},
success: function (data) {
selections = selections.filter( ( el ) => !result.includes( el ) );
// selections = selections.filter(item => item !== userId);
handleListServerResponse(data);
},
error: function (data) {
handleListServerResponse({type:"danger", message:data.responseText})
},
});
}
);
});
function user_handle (userId) {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/deleteuser",
data: {"userid":userId}
});
$("#user-table").bootstrapTable("refresh");
}
$("#user-table").on("click-cell.bs.table", function (field, value, row, $element) { $("#user-table").on("click-cell.bs.table", function (field, value, row, $element) {
if (value === "denied_column_value") { if (value === "denied_column_value") {
ConfirmDialog("btndeluser", "GeneralDeleteModal", $element.id, user_handle); ConfirmDialog("btndeluser", "GeneralDeleteModal", $element.id, user_handle);
@ -562,7 +499,8 @@ $(function() {
}); });
var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference";
selections = window._[func](selections, ids); selections = window._[func](selections, ids);
if (selections.length < 1) { handle_header_buttons();
/*if (selections.length < 1) {
$("#user_delete_selection").addClass("disabled"); $("#user_delete_selection").addClass("disabled");
$("#user_delete_selection").attr("aria-disabled", true); $("#user_delete_selection").attr("aria-disabled", true);
$(".check_head").attr("aria-disabled", true); $(".check_head").attr("aria-disabled", true);
@ -570,6 +508,12 @@ $(function() {
$(".check_head").prop('checked', false); $(".check_head").prop('checked', false);
$(".button_head").attr("aria-disabled", true); $(".button_head").attr("aria-disabled", true);
$(".button_head").addClass("disabled"); $(".button_head").addClass("disabled");
$(".multi_head").attr("aria-disabled", true);
$(".multi_head").addClass("hidden");
$(".multi_selector").attr("aria-disabled", true);
$(".multi_selector").attr("disabled", true);
$('.multi_selector').selectpicker('deselectAll');
$('.multi_selector').selectpicker('refresh');
$(".header_select").attr("disabled", true); $(".header_select").attr("disabled", true);
} else { } else {
$("#user_delete_selection").removeClass("disabled"); $("#user_delete_selection").removeClass("disabled");
@ -578,12 +522,47 @@ $(function() {
$(".check_head").removeAttr("disabled"); $(".check_head").removeAttr("disabled");
$(".button_head").attr("aria-disabled", false); $(".button_head").attr("aria-disabled", false);
$(".button_head").removeClass("disabled"); $(".button_head").removeClass("disabled");
$(".multi_head").attr("aria-disabled", false);
$(".multi_head").removeClass("hidden");
$(".multi_selector").attr("aria-disabled", false);
$(".multi_selector").removeAttr("disabled");
$('.multi_selector').selectpicker('refresh');
$(".header_select").removeAttr("disabled"); $(".header_select").removeAttr("disabled");
} }*/
}); });
}); });
function handle_header_buttons () {
if (selections.length < 1) {
$("#user_delete_selection").addClass("disabled");
$("#user_delete_selection").attr("aria-disabled", true);
$(".check_head").attr("aria-disabled", true);
$(".check_head").attr("disabled", true);
$(".check_head").prop('checked', false);
$(".button_head").attr("aria-disabled", true);
$(".button_head").addClass("disabled");
$(".multi_head").attr("aria-disabled", true);
$(".multi_head").addClass("hidden");
$(".multi_selector").attr("aria-disabled", true);
$(".multi_selector").attr("disabled", true);
$('.multi_selector').selectpicker('deselectAll');
$('.multi_selector').selectpicker('refresh');
$(".header_select").attr("disabled", true);
} else {
$("#user_delete_selection").removeClass("disabled");
$("#user_delete_selection").attr("aria-disabled", false);
$(".check_head").attr("aria-disabled", false);
$(".check_head").removeAttr("disabled");
$(".button_head").attr("aria-disabled", false);
$(".button_head").removeClass("disabled");
$(".multi_head").attr("aria-disabled", false);
$(".multi_head").removeClass("hidden");
$(".multi_selector").attr("aria-disabled", false);
$(".multi_selector").removeAttr("disabled");
$('.multi_selector').selectpicker('refresh');
$(".header_select").removeAttr("disabled");
}
}
/* Function for deleting domain restrictions */ /* Function for deleting domain restrictions */
function TableActions (value, row) { function TableActions (value, row) {
return [ return [
@ -644,6 +623,12 @@ function checkboxFormatter(value, row, index){
function loadSuccess() { function loadSuccess() {
var guest = $(".editable[data-name='name'][data-value='Guest']"); var guest = $(".editable[data-name='name'][data-value='Guest']");
guest.editable("disable"); guest.editable("disable");
$("input:radio.check_head:checked").each(function() {
$(this).prop('checked', false);
});
$(".header_select").each(function() {
$(this).prop("selectedIndex", 0);
});
$(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").editable("disable"); $(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").editable("disable");
$(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").hide(); $(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").hide();
$("input[data-name='admin_role'][data-pk='"+guest.data("pk")+"']").prop("disabled", true); $("input[data-name='admin_role'][data-pk='"+guest.data("pk")+"']").prop("disabled", true);
@ -653,7 +638,99 @@ function loadSuccess() {
$(".user-remove[data-pk='"+guest.data("pk")+"']").hide(); $(".user-remove[data-pk='"+guest.data("pk")+"']").hide();
} }
function handleListServerResponse (data, disableButtons) { function move_header_elements() {
$(".header_select").each(function() {
var item = $(this).parent();
var parent = item.parent().parent();
if (parent.prop('nodeName') === "TH") {
item.prependTo(parent);
}
});
$(".form-check").each(function() {
var item = $(this).parent();
var parent = item.parent().parent();
if (parent.prop('nodeName') === "TH") {
item.prependTo(parent);
}
});
$(".multi_select").each(function() {
var item = $(this);
var parent = item.parent().parent();
if (parent.prop('nodeName') === "TH") {
item.prependTo(parent);
item.addClass("myselect");
}
});
$(".multi_selector").selectpicker();
// Functions have to be here, otherwise the callbacks are not fired if visible columns are changed
$(".multi_head").on("click",function() {
var val = $(this).data("set");
var field = $(this).data("name");
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
var values = $("#" + field).val();
confirmDialog(
"restrictions",
"GeneralChangeModal",
0,
function() {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/editlistusers/" + field,
data: {"pk": result, "value": values, "action": val},
success: function (data) {
handleListServerResponse(data);
},
error: function (data) {
handleListServerResponse({type:"danger", message:data.responseText})
},
});
}
);
});
$("#user_delete_selection").click(function() {
$("#user-table").bootstrapTable("uncheckAll");
});
$("#select_locale").on("change",function() {
selectHeader(this, "locale");
});
$("#select_default_language").on("change",function() {
selectHeader(this, "default_language");
});
$(".check_head").on("change",function() {
var val = $(this).data("set");
var name = $(this).data("name");
var data = $(this).data("val");
checkboxHeader(val, name, data);
});
$(".button_head").on("click",function() {
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
confirmDialog(
"btndeluser",
"GeneralDeleteModal",
0,
function() {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/deleteuser",
data: {"userid": result},
success: function (data) {
selections = selections.filter( ( el ) => !result.includes( el ) );
handleListServerResponse(data);
},
error: function (data) {
handleListServerResponse({type:"danger", message:data.responseText})
},
});
}
);
});
}
function handleListServerResponse (data) {
$("#flash_success").remove(); $("#flash_success").remove();
$("#flash_danger").remove(); $("#flash_danger").remove();
if (!jQuery.isEmptyObject(data)) { if (!jQuery.isEmptyObject(data)) {
@ -679,19 +756,6 @@ function checkboxChange(checkbox, userId, field, field_index) {
}); });
} }
function deactivateHeaderButtons() {
if (selections.length < 1) {
$("#user_delete_selection").addClass("disabled");
$("#user_delete_selection").attr("aria-disabled", true);
$(".check_head").attr("aria-disabled", true);
$(".check_head").attr("disabled", true);
$(".check_head").prop('checked', false);
$(".button_head").attr("aria-disabled", true);
$(".button_head").addClass("disabled");
$(".header_select").attr("disabled", true);
}
}
function selectHeader(element, field) { function selectHeader(element, field) {
if (element.value !== "None") { if (element.value !== "None") {
confirmDialog(element.id, "GeneralChangeModal", 0, function () { confirmDialog(element.id, "GeneralChangeModal", 0, function () {
@ -705,6 +769,8 @@ function selectHeader(element, field) {
}, },
success: handleListServerResponse, success: handleListServerResponse,
}); });
},function() {
$(element).prop("selectedIndex", 0);
}); });
} }
} }
@ -723,6 +789,10 @@ function checkboxHeader(CheckboxState, field, field_index) {
handleListServerResponse (data, true) handleListServerResponse (data, true)
}, },
}); });
},function() {
$("input:radio.check_head:checked").each(function() {
$(this).prop('checked', false);
});
}); });
} }
@ -758,3 +828,12 @@ function queryParams(params)
function storeLocation() { function storeLocation() {
window.sessionStorage.setItem("back", window.location.pathname); window.sessionStorage.setItem("back", window.location.pathname);
} }
function user_handle (userId) {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/deleteuser",
data: {"userid":userId}
});
$("#user-table").bootstrapTable("refresh");
}

View File

@ -115,7 +115,6 @@ class TaskEmail(CalibreTask):
self.results = dict() self.results = dict()
def prepare_message(self): def prepare_message(self):
log.debug("prepare email message for sending")
message = MIMEMultipart() message = MIMEMultipart()
message['to'] = self.recipent message['to'] = self.recipent
message['from'] = self.settings["mail_from"] message['from'] = self.settings["mail_from"]
@ -171,11 +170,10 @@ class TaskEmail(CalibreTask):
# redirect output to logfile on python2 on python3 debugoutput is caught with overwritten # redirect output to logfile on python2 on python3 debugoutput is caught with overwritten
# _print_debug function # _print_debug function
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
log.debug("Redirect output on python2 for email")
org_smtpstderr = smtplib.stderr org_smtpstderr = smtplib.stderr
smtplib.stderr = logger.StderrLogger('worker.smtp') smtplib.stderr = logger.StderrLogger('worker.smtp')
log.debug("Start send email") log.debug("Start sending email")
if use_ssl == 2: if use_ssl == 2:
self.asyncSMTP = EmailSSL(self.settings["mail_server"], self.settings["mail_port"], self.asyncSMTP = EmailSSL(self.settings["mail_server"], self.settings["mail_port"],
timeout=timeout) timeout=timeout)
@ -188,7 +186,6 @@ class TaskEmail(CalibreTask):
if use_ssl == 1: if use_ssl == 1:
self.asyncSMTP.starttls() self.asyncSMTP.starttls()
if self.settings["mail_password"]: if self.settings["mail_password"]:
log.debug("Login to email server")
self.asyncSMTP.login(str(self.settings["mail_login"]), str(self.settings["mail_password"])) self.asyncSMTP.login(str(self.settings["mail_login"]), str(self.settings["mail_password"]))
# Convert message to something to send # Convert message to something to send
@ -196,7 +193,6 @@ class TaskEmail(CalibreTask):
gen = Generator(fp, mangle_from_=False) gen = Generator(fp, mangle_from_=False)
gen.flatten(msg) gen.flatten(msg)
log.debug("Sending email")
self.asyncSMTP.sendmail(self.settings["mail_from"], self.recipent, fp.getvalue()) self.asyncSMTP.sendmail(self.settings["mail_from"], self.recipent, fp.getvalue())
self.asyncSMTP.quit() self.asyncSMTP.quit()
self._handleSuccess() self._handleSuccess()

View File

@ -1,5 +1,5 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% macro user_table_row(parameter, edit_text, show_text, validate, button=False, id=0) -%} {% macro user_table_row(parameter, edit_text, show_text, validate, elements=False) -%}
<th data-field="{{ parameter }}" id="{{ parameter }}" <th data-field="{{ parameter }}" id="{{ parameter }}"
data-name="{{ parameter }}" data-name="{{ parameter }}"
data-visible="{{visiblility.get(parameter)}}" data-visible="{{visiblility.get(parameter)}}"
@ -11,8 +11,22 @@
data-sortable="true" data-sortable="true"
{% endif %} {% endif %}
{% if validate %}data-edit-validate="{{ _('This Field is Required') }}"{% endif %}> {% if validate %}data-edit-validate="{{ _('This Field is Required') }}"{% endif %}>
{% if button %} {% if elements %}
<!--div><button data-id="{{id}}" data-toggle="modal" data-target="#restrictModal" class="btn btn-default button_head disabled" aria-disabled="true">{{edit_text}}</button></div--><br> <div class="multi_select">
<select class="multi_selector" id="{{ parameter }}" data-live-search="true" data-style="btn-default" data-dropup-auto="false" aria-disabled="true" multiple disabled>
{% for tag in elements %}
<option class="tags_click" value="{{tag.id}}">{% if tag.name %}{{tag.name}}{% else %}{{tag.value}}{% endif %}</option>
{% endfor %}
</select>
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group">
<div class="multi_head btn btn-default hidden" data-set="remove" data-name="{{parameter}}" aria-disabled="true">{{_('Remove')}}</div>
</div>
<div class="btn-group" role="group">
<div class="multi_head btn btn-default hidden" data-set="add" data-name="{{parameter}}" aria-disabled="true">{{_('Add')}}</div>
</div>
</div>
</div>
{% endif %} {% endif %}
{{ show_text }} {{ show_text }}
</th> </th>
@ -25,14 +39,14 @@
data-formatter="checkboxFormatter"> data-formatter="checkboxFormatter">
<div class="form-check"> <div class="form-check">
<div> <div>
<label>
<input type="radio" class="check_head" data-val={{value.get(array_field)}} name="options_{{array_field}}" data-name="{{parameter}}" disabled>{{_('Deny')}} <input type="radio" class="check_head" data-set="false" data-val={{value.get(array_field)}} name="options_{{array_field}}" data-name="{{parameter}}" disabled>{{_('Deny')}}
</label>
</div> </div>
<div> <div>
<label>
<input type="radio" class="check_head" data-val={{value.get(array_field)}} name="options_{{array_field}}" data-name="{{parameter}}" disabled>{{_('Allow')}} <input type="radio" class="check_head" data-set="true" data-val={{value.get(array_field)}} name="options_{{array_field}}" data-name="{{parameter}}" disabled>{{_('Allow')}}
</label>
</div> </div>
</div> </div>
{{show_text}} {{show_text}}
@ -51,6 +65,7 @@
{% if validate %}data-edit-validate="{{ _('This Field is Required') }}"{% endif %}> {% if validate %}data-edit-validate="{{ _('This Field is Required') }}"{% endif %}>
<div> <div>
<select id="select_{{ parameter }}" class="header_select" disabled=""> <select id="select_{{ parameter }}" class="header_select" disabled="">
<option value="none">{{ _('Select...') }}</option>
<option value="all">{{ _('Show All') }}</option> <option value="all">{{ _('Show All') }}</option>
{% for language in languages %} {% for language in languages %}
<option value="{{language.lang_code}}">{{language.name}}</option> <option value="{{language.lang_code}}">{{language.name}}</option>
@ -87,6 +102,7 @@
{% block header %} {% block header %}
<link href="{{ url_for('static', filename='css/libs/bootstrap-table.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/libs/bootstrap-table.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/libs/bootstrap-editable.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/libs/bootstrap-editable.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/libs/bootstrap-select.min.css') }}" rel="stylesheet" >
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2 class="{{page}}">{{_(title)}}</h2> <h2 class="{{page}}">{{_(title)}}</h2>
@ -107,10 +123,10 @@
{{ user_table_row('kindle_mail', _('Enter Kindle E-mail Address'), _('Kindle E-mail'), false) }} {{ user_table_row('kindle_mail', _('Enter Kindle E-mail Address'), _('Kindle E-mail'), false) }}
{{ user_select_translations('locale', url_for('admin.table_get_locale'), _('Locale'), true) }} {{ user_select_translations('locale', url_for('admin.table_get_locale'), _('Locale'), true) }}
{{ user_select_languages('default_language', url_for('admin.table_get_default_lang'), _('Visible Book Languages'), true) }} {{ user_select_languages('default_language', url_for('admin.table_get_default_lang'), _('Visible Book Languages'), true) }}
{{ user_table_row('denied_tags', _("Edit Denied Tags"), _("Denied Tags"), false, true, 0) }} {{ user_table_row('denied_tags', _("Edit Denied Tags"), _("Denied Tags"), false, tags) }}
{{ user_table_row('allowed_tags', _("Edit Allowed Tags"), _("Allowed Tags"), false, true, 1) }} {{ user_table_row('allowed_tags', _("Edit Allowed Tags"), _("Allowed Tags"), false, tags) }}
{{ user_table_row('allowed_column_value', _("Edit Allowed Column Values"), _("Allowed Column Values"), false, true, 2) }} {{ user_table_row('allowed_column_value', _("Edit Allowed Column Values"), _("Allowed Column Values"), false, custom_values) }}
{{ user_table_row('denied_column_value', _("Edit Denied Column Values"), _("Denied Columns Values"), false, true, 3) }} {{ user_table_row('denied_column_value', _("Edit Denied Column Values"), _("Denied Columns Values"), false, custom_values) }}
{{ user_checkbox_row("role", "admin_role", _('Admin'), visiblility, all_roles)}} {{ user_checkbox_row("role", "admin_role", _('Admin'), visiblility, all_roles)}}
{{ user_checkbox_row("role", "passwd_role", _('Change Password'), visiblility, all_roles)}} {{ user_checkbox_row("role", "passwd_role", _('Change Password'), visiblility, all_roles)}}
{{ user_checkbox_row("role", "upload_role",_('Upload'), visiblility, all_roles)}} {{ user_checkbox_row("role", "upload_role",_('Upload'), visiblility, all_roles)}}
@ -151,7 +167,7 @@
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table.min.js') }}"></script> <script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table-editable.min.js') }}"></script> <script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table-editable.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-editable.min.js') }}"></script> <script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-editable.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/bootstrap-select.min.js')}}"></script>
<script src="{{ url_for('static', filename='js/table.js') }}"></script> <script src="{{ url_for('static', filename='js/table.js') }}"></script>
<script>
</script>
{% endblock %} {% endblock %}