Merge branch 'master' of https://github.com/janeczku/calibre-web
This commit is contained in:
commit
e57229e670
35
cps/admin.py
35
cps/admin.py
|
@ -289,15 +289,30 @@ def list_users():
|
|||
@login_required
|
||||
@admin_required
|
||||
def delete_user():
|
||||
user_id = request.values.get('userid', -1)
|
||||
content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).one_or_none()
|
||||
try:
|
||||
message = _delete_user(content)
|
||||
return Response(json.dumps({'type': "success", 'message': message}), mimetype='application/json')
|
||||
except Exception as ex:
|
||||
return Response(json.dumps({'type': "danger", 'message':str(ex)}), mimetype='application/json')
|
||||
user_ids = request.form.to_dict(flat=False)
|
||||
if "userid[]" in user_ids:
|
||||
users = ub.session.query(ub.User).filter(ub.User.id.in_(user_ids['userid[]'])).all()
|
||||
elif "userid" in user_ids:
|
||||
users = ub.session.query(ub.User).filter(ub.User.id == user_ids['userid'][0]).all()
|
||||
count = 0
|
||||
errors = list()
|
||||
success = list()
|
||||
if not users:
|
||||
log.error("User not found")
|
||||
return Response(json.dumps({'type': "danger", 'message':_("User not found")}), mimetype='application/json')
|
||||
return Response(json.dumps({'type': "danger", 'message': _("User not found")}), mimetype='application/json')
|
||||
for user in users:
|
||||
try:
|
||||
message = _delete_user(user)
|
||||
count += 1
|
||||
except Exception as ex:
|
||||
errors.append({'type': "danger", 'message': str(ex)})
|
||||
|
||||
if count == 1:
|
||||
success = [{'type': "success", 'message': message}]
|
||||
elif count > 1:
|
||||
success = [{'type': "success", 'message': _("{} users deleted successfully").format(count)}]
|
||||
success.extend(errors)
|
||||
return Response(json.dumps(success), mimetype='application/json')
|
||||
|
||||
@admi.route("/ajax/getlocale")
|
||||
@login_required
|
||||
|
@ -367,9 +382,9 @@ def edit_list_user(param):
|
|||
if not ub.session.query(ub.User).\
|
||||
filter(ub.User.role.op('&')(constants.ROLE_ADMIN) == constants.ROLE_ADMIN,
|
||||
ub.User.id != user.id).count():
|
||||
return Response(json.dumps({'type': "danger",
|
||||
return Response(json.dumps([{'type': "danger",
|
||||
'message':_(u"No admin user remaining, can't remove admin role",
|
||||
nick=user.name)}), mimetype='application/json')
|
||||
nick=user.name)}]), mimetype='application/json')
|
||||
user.role &= ~int(vals['field_index'])
|
||||
elif param.startswith('sidebar'):
|
||||
if user.name == "Guest" and int(vals['field_index']) == constants.SIDEBAR_READ_AND_UNREAD:
|
||||
|
|
|
@ -625,7 +625,10 @@ class CalibreDB():
|
|||
outcome = list()
|
||||
elementlist = {ele.id: ele for ele in inputlist}
|
||||
for entry in state:
|
||||
try:
|
||||
outcome.append(elementlist[entry])
|
||||
except KeyError:
|
||||
pass
|
||||
del elementlist[entry]
|
||||
for entry in elementlist:
|
||||
outcome.append(elementlist[entry])
|
||||
|
|
|
@ -1211,6 +1211,6 @@ def merge_list_book():
|
|||
element.format,
|
||||
element.uncompressed_size,
|
||||
to_name))
|
||||
delete_book(from_book.id,"", True) # json_resp =
|
||||
delete_book(from_book.id,"", True)
|
||||
return json.dumps({'success': True})
|
||||
return ""
|
||||
|
|
|
@ -178,6 +178,19 @@ $("#delete_confirm").click(function() {
|
|||
|
||||
}
|
||||
});
|
||||
$("#books-table").bootstrapTable("refresh");
|
||||
/*$.ajax({
|
||||
method:"get",
|
||||
url: window.location.pathname + "/../../ajax/listbooks",
|
||||
async: true,
|
||||
timeout: 900,
|
||||
success:function(data) {
|
||||
|
||||
|
||||
$("#book-table").bootstrapTable("load", data);
|
||||
loadSuccess();
|
||||
}
|
||||
});*/
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -511,22 +511,36 @@ $(function() {
|
|||
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}
|
||||
});
|
||||
$.ajax({
|
||||
method:"get",
|
||||
url: window.location.pathname + "/../../ajax/listusers",
|
||||
async: true,
|
||||
timeout: 900,
|
||||
success:function(data) {
|
||||
$("#user-table").bootstrapTable("load", data);
|
||||
loadSuccess();
|
||||
}
|
||||
});
|
||||
$("#user-table").bootstrapTable("refresh");
|
||||
}
|
||||
|
||||
$("#user-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
||||
|
@ -642,23 +656,13 @@ function handleListServerResponse (data, disableButtons) {
|
|||
$("#flash_success").remove();
|
||||
$("#flash_danger").remove();
|
||||
if (!jQuery.isEmptyObject(data)) {
|
||||
$( ".navbar" ).after( '<div class="row-fluid text-center" style="margin-top: -20px;">' +
|
||||
'<div id="flash_'+data.type+'" class="alert alert-'+data.type+'">'+data.message+'</div>' +
|
||||
data.forEach(function(item) {
|
||||
$(".navbar").after('<div class="row-fluid text-center" style="margin-top: -20px;">' +
|
||||
'<div id="flash_' + item.type + '" class="alert alert-' + item.type + '">' + item.message + '</div>' +
|
||||
'</div>');
|
||||
}
|
||||
$.ajax({
|
||||
method: "get",
|
||||
url: window.location.pathname + "/../../ajax/listusers",
|
||||
async: true,
|
||||
timeout: 900,
|
||||
success: function (data) {
|
||||
$("#user-table").bootstrapTable("load", data);
|
||||
if (disableButtons) {
|
||||
deactivateHeaderButtons();
|
||||
}
|
||||
loadSuccess();
|
||||
}
|
||||
});
|
||||
}
|
||||
$("#user-table").bootstrapTable("refresh");
|
||||
}
|
||||
|
||||
|
||||
|
@ -675,6 +679,7 @@ 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);
|
||||
|
@ -683,6 +688,7 @@ function deactivateHeaderButtons() {
|
|||
$(".button_head").attr("aria-disabled", true);
|
||||
$(".button_head").addClass("disabled");
|
||||
$(".header_select").attr("disabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
function selectHeader(element, field) {
|
||||
|
@ -719,7 +725,7 @@ function checkboxHeader(CheckboxState, field, field_index) {
|
|||
});
|
||||
}
|
||||
|
||||
function deleteUser(a,b){
|
||||
function deleteUser(a,id){
|
||||
confirmDialog(
|
||||
"btndeluser",
|
||||
"GeneralDeleteModal",
|
||||
|
@ -728,8 +734,12 @@ function deleteUser(a,b){
|
|||
$.ajax({
|
||||
method:"post",
|
||||
url: window.location.pathname + "/../../ajax/deleteuser",
|
||||
data: {"userid":b},
|
||||
success: handleListServerResponse,
|
||||
data: {"userid":id},
|
||||
success: function (data) {
|
||||
userId = parseInt(id, 10);
|
||||
selections = selections.filter(item => item !== userId);
|
||||
handleListServerResponse(data);
|
||||
},
|
||||
error: function (data) {
|
||||
handleListServerResponse({type:"danger", message:data.responseText})
|
||||
},
|
||||
|
|
|
@ -788,7 +788,7 @@ def list_books():
|
|||
|
||||
if state:
|
||||
if search:
|
||||
books = calibre_db.search_query(search)
|
||||
books = calibre_db.search_query(search).all()
|
||||
filtered_count = len(books)
|
||||
else:
|
||||
books = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()).all()
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,4 @@
|
|||
|
||||
output_list = Array();
|
||||
|
||||
/* Level - 0: Summary; 1: Failed; 2: All; 3: Skipped 4: Error*/
|
||||
|
@ -24,9 +25,9 @@ function showCase(level) {
|
|||
row.classList.add('hiddenRow');
|
||||
}
|
||||
}
|
||||
// Show skipped if all or skipped or summary problems selected
|
||||
// Show skipped if all or skipped selected
|
||||
if (id.substr(0,2) == 'st') {
|
||||
if (level ==2 || level ==3 || level == 5) {
|
||||
if (level ==2 || level ==3) {
|
||||
row.classList.remove('hiddenRow');
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user