Result for testrun
Added mass delete of users refactores user table refresh Bugfix for sorting with selected users Bugfix delete books #1938
This commit is contained in:
parent
6e5a1a1f4d
commit
bb4749c65b
37
cps/admin.py
37
cps/admin.py
|
@ -289,15 +289,30 @@ def list_users():
|
||||||
@login_required
|
@login_required
|
||||||
@admin_required
|
@admin_required
|
||||||
def delete_user():
|
def delete_user():
|
||||||
user_id = request.values.get('userid', -1)
|
user_ids = request.form.to_dict(flat=False)
|
||||||
content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).one_or_none()
|
if "userid[]" in user_ids:
|
||||||
try:
|
users = ub.session.query(ub.User).filter(ub.User.id.in_(user_ids['userid[]'])).all()
|
||||||
message = _delete_user(content)
|
elif "userid" in user_ids:
|
||||||
return Response(json.dumps({'type': "success", 'message': message}), mimetype='application/json')
|
users = ub.session.query(ub.User).filter(ub.User.id == user_ids['userid'][0]).all()
|
||||||
except Exception as ex:
|
count = 0
|
||||||
return Response(json.dumps({'type': "danger", 'message':str(ex)}), mimetype='application/json')
|
errors = list()
|
||||||
log.error("User not found")
|
success = list()
|
||||||
return Response(json.dumps({'type': "danger", 'message':_("User not found")}), mimetype='application/json')
|
if not users:
|
||||||
|
log.error("User not found")
|
||||||
|
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")
|
@admi.route("/ajax/getlocale")
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -367,9 +382,9 @@ def edit_list_user(param):
|
||||||
if not ub.session.query(ub.User).\
|
if not ub.session.query(ub.User).\
|
||||||
filter(ub.User.role.op('&')(constants.ROLE_ADMIN) == constants.ROLE_ADMIN,
|
filter(ub.User.role.op('&')(constants.ROLE_ADMIN) == constants.ROLE_ADMIN,
|
||||||
ub.User.id != user.id).count():
|
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",
|
'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'])
|
user.role &= ~int(vals['field_index'])
|
||||||
elif param.startswith('sidebar'):
|
elif param.startswith('sidebar'):
|
||||||
if user.name == "Guest" and int(vals['field_index']) == constants.SIDEBAR_READ_AND_UNREAD:
|
if user.name == "Guest" and int(vals['field_index']) == constants.SIDEBAR_READ_AND_UNREAD:
|
||||||
|
|
|
@ -625,7 +625,10 @@ class CalibreDB():
|
||||||
outcome = list()
|
outcome = list()
|
||||||
elementlist = {ele.id: ele for ele in inputlist}
|
elementlist = {ele.id: ele for ele in inputlist}
|
||||||
for entry in state:
|
for entry in state:
|
||||||
outcome.append(elementlist[entry])
|
try:
|
||||||
|
outcome.append(elementlist[entry])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
del elementlist[entry]
|
del elementlist[entry]
|
||||||
for entry in elementlist:
|
for entry in elementlist:
|
||||||
outcome.append(elementlist[entry])
|
outcome.append(elementlist[entry])
|
||||||
|
|
|
@ -1185,6 +1185,6 @@ def merge_list_book():
|
||||||
element.format,
|
element.format,
|
||||||
element.uncompressed_size,
|
element.uncompressed_size,
|
||||||
to_name))
|
to_name))
|
||||||
delete_book(from_book.id,"", True) # json_resp =
|
delete_book(from_book.id,"", True)
|
||||||
return json.dumps({'success': True})
|
return json.dumps({'success': True})
|
||||||
return ""
|
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 {
|
} else {
|
||||||
|
|
|
@ -511,22 +511,36 @@ $(function() {
|
||||||
var data = $(this).data("val");
|
var data = $(this).data("val");
|
||||||
checkboxHeader(val, name, data);
|
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) {
|
function user_handle (userId) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"post",
|
method:"post",
|
||||||
url: window.location.pathname + "/../../ajax/deleteuser",
|
url: window.location.pathname + "/../../ajax/deleteuser",
|
||||||
data: {"userid":userId}
|
data: {"userid":userId}
|
||||||
});
|
});
|
||||||
$.ajax({
|
$("#user-table").bootstrapTable("refresh");
|
||||||
method:"get",
|
|
||||||
url: window.location.pathname + "/../../ajax/listusers",
|
|
||||||
async: true,
|
|
||||||
timeout: 900,
|
|
||||||
success:function(data) {
|
|
||||||
$("#user-table").bootstrapTable("load", data);
|
|
||||||
loadSuccess();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#user-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
$("#user-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
||||||
|
@ -642,23 +656,13 @@ function handleListServerResponse (data, disableButtons) {
|
||||||
$("#flash_success").remove();
|
$("#flash_success").remove();
|
||||||
$("#flash_danger").remove();
|
$("#flash_danger").remove();
|
||||||
if (!jQuery.isEmptyObject(data)) {
|
if (!jQuery.isEmptyObject(data)) {
|
||||||
$( ".navbar" ).after( '<div class="row-fluid text-center" style="margin-top: -20px;">' +
|
data.forEach(function(item) {
|
||||||
'<div id="flash_'+data.type+'" class="alert alert-'+data.type+'">'+data.message+'</div>' +
|
$(".navbar").after('<div class="row-fluid text-center" style="margin-top: -20px;">' +
|
||||||
'</div>');
|
'<div id="flash_' + item.type + '" class="alert alert-' + item.type + '">' + item.message + '</div>' +
|
||||||
|
'</div>');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
$.ajax({
|
$("#user-table").bootstrapTable("refresh");
|
||||||
method: "get",
|
|
||||||
url: window.location.pathname + "/../../ajax/listusers",
|
|
||||||
async: true,
|
|
||||||
timeout: 900,
|
|
||||||
success: function (data) {
|
|
||||||
$("#user-table").bootstrapTable("load", data);
|
|
||||||
if (disableButtons) {
|
|
||||||
deactivateHeaderButtons();
|
|
||||||
}
|
|
||||||
loadSuccess();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -675,14 +679,16 @@ function checkboxChange(checkbox, userId, field, field_index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deactivateHeaderButtons() {
|
function deactivateHeaderButtons() {
|
||||||
$("#user_delete_selection").addClass("disabled");
|
if (selections.length < 1) {
|
||||||
$("#user_delete_selection").attr("aria-disabled", true);
|
$("#user_delete_selection").addClass("disabled");
|
||||||
$(".check_head").attr("aria-disabled", true);
|
$("#user_delete_selection").attr("aria-disabled", true);
|
||||||
$(".check_head").attr("disabled", true);
|
$(".check_head").attr("aria-disabled", true);
|
||||||
$(".check_head").prop('checked', false);
|
$(".check_head").attr("disabled", true);
|
||||||
$(".button_head").attr("aria-disabled", true);
|
$(".check_head").prop('checked', false);
|
||||||
$(".button_head").addClass("disabled");
|
$(".button_head").attr("aria-disabled", true);
|
||||||
$(".header_select").attr("disabled", true);
|
$(".button_head").addClass("disabled");
|
||||||
|
$(".header_select").attr("disabled", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectHeader(element, field) {
|
function selectHeader(element, field) {
|
||||||
|
@ -719,7 +725,7 @@ function checkboxHeader(CheckboxState, field, field_index) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteUser(a,b){
|
function deleteUser(a,id){
|
||||||
confirmDialog(
|
confirmDialog(
|
||||||
"btndeluser",
|
"btndeluser",
|
||||||
"GeneralDeleteModal",
|
"GeneralDeleteModal",
|
||||||
|
@ -728,8 +734,12 @@ function deleteUser(a,b){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"post",
|
method:"post",
|
||||||
url: window.location.pathname + "/../../ajax/deleteuser",
|
url: window.location.pathname + "/../../ajax/deleteuser",
|
||||||
data: {"userid":b},
|
data: {"userid":id},
|
||||||
success: handleListServerResponse,
|
success: function (data) {
|
||||||
|
userId = parseInt(id, 10);
|
||||||
|
selections = selections.filter(item => item !== userId);
|
||||||
|
handleListServerResponse(data);
|
||||||
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
handleListServerResponse({type:"danger", message:data.responseText})
|
handleListServerResponse({type:"danger", message:data.responseText})
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
output_list = Array();
|
output_list = Array();
|
||||||
|
|
||||||
/* Level - 0: Summary; 1: Failed; 2: All; 3: Skipped 4: Error*/
|
/* Level - 0: Summary; 1: Failed; 2: All; 3: Skipped 4: Error*/
|
||||||
|
@ -24,9 +25,9 @@ function showCase(level) {
|
||||||
row.classList.add('hiddenRow');
|
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 (id.substr(0,2) == 'st') {
|
||||||
if (level ==2 || level ==3 || level == 5) {
|
if (level ==2 || level ==3) {
|
||||||
row.classList.remove('hiddenRow');
|
row.classList.remove('hiddenRow');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user