diff --git a/cps/admin.py b/cps/admin.py index c7210f3f..014f32ef 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -217,25 +217,34 @@ def view_configuration(): @admin_required def edit_user_table(): visibility = current_user.view_settings.get('useredit', {}) - allUser = ub.session.query(ub.User).all() - return render_title_template("user_table.html", users=allUser, visiblility=visibility, - title=_(u"Edit Users"), page="usertable") + allUser = ub.session.query(ub.User) + if not config.config_anonbrowse: + allUser = allUser.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) != constants.ROLE_ANONYMOUS) + + return render_title_template("user_table.html", + users=allUser.all(), + visiblility=visibility, + all_roles = constants.ALL_ROLES, + title=_(u"Edit Users"), + page="usertable") @admi.route("/axjax/listusers") @login_required @admin_required def list_users(): off = request.args.get("offset") or 0 - limit = request.args.get("limit") or 10 - - total_count = ub.session.query(ub.User).count() + limit = request.args.get("limit") or 40 search = request.args.get("search") + + all_user = ub.session.query(ub.User) + if not config.config_anonbrowse: + all_user = all_user.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) != constants.ROLE_ANONYMOUS) + total_count = all_user.count() if search: - users = ub.session.query(ub.User).filter().offset(off).limit(limit).all() + users = all_user.filter().offset(off).limit(limit).all() filtered_count = users.length() - # entries, filtered_count, pagination = calibre_db.get_search_results(search, off, order, limit) else: - users = ub.session.query(ub.User).offset(off).limit(limit).all() + users = all_user.offset(off).limit(limit).all() filtered_count = total_count table_entries = {'totalNotFiltered': total_count, 'total': filtered_count, "rows": users} @@ -251,7 +260,11 @@ def list_users(): @admin_required def edit_list_user(param): vals = request.form.to_dict() - user = ub.session.query(ub.User).filter(ub.User.id == vals['pk']).one_or_none() # ub.User.query calibre_db.get_book(vals['pk']) + all_user = ub.session.query(ub.User) + if not config.config_anonbrowse: + all_user = all_user.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) != constants.ROLE_ANONYMOUS) + + user = all_user.filter(ub.User.id == vals['pk']).one_or_none() if param =='nickname': if not ub.session.query(ub.User).filter(ub.User.nickname == vals['value']).scalar(): user.nickname = vals['value'] diff --git a/cps/static/css/style.css b/cps/static/css/style.css index 8c99aaa0..664cdb9a 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -51,10 +51,12 @@ body h2 { color:#444; } -a, .danger,.book-remove, .editable-empty, .editable-empty:hover { color: #45b29d; } +a, .danger, .book-remove, .user-remove, .editable-empty, .editable-empty:hover { color: #45b29d; } .book-remove:hover { color: #23527c; } +.user-remove:hover { color: #23527c; } + .btn-default a { color: #444; } .btn-default a:hover { diff --git a/cps/static/js/table.js b/cps/static/js/table.js index 116a72d6..51134fa1 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -429,7 +429,8 @@ $(function() { }, }); - $("#user-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", + + /*$("#user-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) { var rows = rowsAfter; @@ -440,7 +441,7 @@ $(function() { var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { return row.id; }); - }); + });*/ }); /* Function for deleting domain restrictions */ @@ -472,6 +473,15 @@ function EbookActions (value, row) { ].join(""); } +/* Function for deleting books */ +function UserActions (value, row) { + return [ + "