|
@@ -5,15 +5,15 @@ from bot.keyboards import user_manage_kb,register_kb
|
|
|
|
|
|
|
|
|
async def list_users(message: types.Message):
|
|
|
- Db = database.Database()
|
|
|
- if not Db.sql_simple_check(sql=f"select tg_id from user_table where tg_id ={message.from_user.id}") or \
|
|
|
- not Db.sql_simple_check(sql=f"select approved from user_table where tg_id={message.from_user.id}"):
|
|
|
+ db = database.Database()
|
|
|
+ if not db.sql_simple_check(sql=f"select tg_id from user_table where tg_id ={message.from_user.id}") or \
|
|
|
+ not db.sql_simple_check(sql=f"select approved from user_table where tg_id={message.from_user.id}"):
|
|
|
await message.delete()
|
|
|
await message.answer("Команды станут доступны после регистрации", reply_markup=register_kb)
|
|
|
- if not Db.sql_parse_users("select id,name,phone from user_table where approved = '0'"):
|
|
|
+ if not db.sql_parse_users("select id,name,phone from user_table where approved = '0'"):
|
|
|
await message.answer('Заявки на регистрацию отсутствуют')
|
|
|
else:
|
|
|
- data = Db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
+ data = db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
await message.answer(beauty_reg_request(data[0]),
|
|
|
reply_markup=user_manage_kb(f"accept:{data[0]['ID']}",
|
|
|
f"deny:{data[0]['ID']}",
|
|
@@ -23,8 +23,8 @@ async def list_users(message: types.Message):
|
|
|
|
|
|
|
|
|
async def next_user_page(call: types.CallbackQuery):
|
|
|
- Db = database.Database()
|
|
|
- data = Db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
+ db = database.Database()
|
|
|
+ data = db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
index = int(call.data.split(":")[1]) + 1
|
|
|
|
|
|
if not data:
|
|
@@ -43,8 +43,8 @@ async def next_user_page(call: types.CallbackQuery):
|
|
|
|
|
|
|
|
|
async def prev_user_page(call: types.CallbackQuery):
|
|
|
- Db = database.Database()
|
|
|
- data = Db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
+ db = database.Database()
|
|
|
+ data = db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
index = int(call.data.split(":")[1])-1
|
|
|
# print(f"prev_index{index}")
|
|
|
if not data:
|
|
@@ -62,21 +62,21 @@ async def prev_user_page(call: types.CallbackQuery):
|
|
|
|
|
|
|
|
|
async def accept_user(call: types.CallbackQuery):
|
|
|
- Db = database.Database()
|
|
|
- data = Db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
- # data = Db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
+ db = database.Database()
|
|
|
+ data = db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
+ # data = db.sql_parse_users("select id,name,phone from user_table where approved = '0'")
|
|
|
index = int(call.message.reply_markup.inline_keyboard[1][1].text.split("/")[0])-1
|
|
|
# print(index)
|
|
|
|
|
|
|
|
|
if len(data) == 1:
|
|
|
user_id = data[index]['ID']
|
|
|
- Db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
+ db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
await call.message.delete()
|
|
|
await call.message.answer('Заявки на регистрацию отсутствуют')
|
|
|
elif index == 0:
|
|
|
user_id = data[index]['ID']
|
|
|
- Db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
+ db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
await call.message.edit_text(beauty_reg_request(data[index+1]),
|
|
|
reply_markup=user_manage_kb(f"accept:{user_id}",
|
|
|
f"deny:{user_id}",
|
|
@@ -85,7 +85,7 @@ async def accept_user(call: types.CallbackQuery):
|
|
|
f"{index+1}/{len(data) - 1}"))
|
|
|
elif index == len(data)-1:
|
|
|
user_id = data[index]['ID']
|
|
|
- Db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
+ db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
await call.message.edit_text(beauty_reg_request(data[index-1]),
|
|
|
reply_markup=user_manage_kb(f"accept:{user_id}",
|
|
|
f"deny:{user_id}",
|
|
@@ -94,7 +94,7 @@ async def accept_user(call: types.CallbackQuery):
|
|
|
f"{index}/{len(data) - 1}"))
|
|
|
else:
|
|
|
user_id = data[index]['ID']
|
|
|
- Db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
+ db.sql_query_send(f"UPDATE booking.user_table SET approved='1' WHERE id={user_id}")
|
|
|
await call.message.edit_text(beauty_reg_request(data[index-1]),
|
|
|
reply_markup=user_manage_kb(f"accept:{user_id}",
|
|
|
f"deny:{user_id}",
|