diff --git a/functions.py b/functions.py index a80cf07..36f7489 100644 --- a/functions.py +++ b/functions.py @@ -262,6 +262,6 @@ def copy_template(template, new_project, data_session, current_user): def save_admin_data(data, data_session): - user = data_session.query(User).filter(User.id == data[0][5:]).first() + user = data_session.query(User).filter(User.id == data[0].split('_')[-1]).first() if user.role != data[1]: user.role = data[1] diff --git a/main.py b/main.py index cab86c2..436c7ef 100644 --- a/main.py +++ b/main.py @@ -72,7 +72,14 @@ def admin(): data_form = request.form.to_dict() del data_form['csrf_token'], data_form['submit'] data_form = list(map(lambda x: (x[0], x[1]), data_form.items())) - list(map(lambda x: save_admin_data(x, data_session), data_form)) + list( + map(lambda x: save_admin_data(x, data_session), list(filter(lambda x: 'role_' in x[0], data_form)))) + list_id = list(map(lambda user: int(user[0].split('_')[-1]), list(filter(lambda x: 'active_' in x[0], data_form)))) + for user in users: + if user.id not in list_id: + user.activated = 0 + else: + user.activated = 1 data_session.commit() return render_template('admin.html', title='Панель админа', roles=roles, users=users, form=form) abort(404) diff --git a/static/css/admin.css b/static/css/admin.css index a140031..576956c 100644 --- a/static/css/admin.css +++ b/static/css/admin.css @@ -5,7 +5,7 @@ flex-direction: column; align-items: center; } -.roles_block { +.admin_block { width: 90%; height: 35vw; background-color: #EDCBB0; @@ -13,10 +13,10 @@ overflow-y: auto; overflow-x: hidden; } -.roles_block::-webkit-scrollbar { +.admin_block::-webkit-scrollbar { width: 0.8vw; /* ширина scrollbar */ } -.roles_block::-webkit-scrollbar-thumb { +.admin_block::-webkit-scrollbar-thumb { background-color: #d49d51; /* цвет плашки */ border-radius: 5vw; /* закругления плашки */ border: 0.25vw solid #ffffff; @@ -53,7 +53,7 @@ color: #000000 !important; font-size: 2vw; } -.roles_title { +.admine_title { font-size: 3vw; } .link_to_user { @@ -89,4 +89,7 @@ display: flex; flex-direction: column; align-items: center; +} +.user_active { + margin-left: 1vw; } \ No newline at end of file diff --git a/templates/admin.html b/templates/admin.html index ec3f6c0..99d218f 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -1,10 +1,10 @@ {% extends "base.html" %} {% block content %}