mirror of
https://github.com/koloideal/Quizzi.git
synced 2026-06-10 10:25:28 +03:00
commit
This commit is contained in:
@@ -15,6 +15,7 @@ class AdminTestsSG(StatesGroup):
|
|||||||
tests_list = State()
|
tests_list = State()
|
||||||
test_detail = State()
|
test_detail = State()
|
||||||
share_test = State()
|
share_test = State()
|
||||||
|
edit_menu = State()
|
||||||
edit_password = State()
|
edit_password = State()
|
||||||
edit_attempts = State()
|
edit_attempts = State()
|
||||||
edit_group = State()
|
edit_group = State()
|
||||||
|
|||||||
@@ -66,19 +66,19 @@ async def get_test_detail(test_dao: FromDishka[TestDAO], test_repo: FromDishka[T
|
|||||||
status = "🟢 Активен" if test.is_active else "🔴 Деактивирован"
|
status = "🟢 Активен" if test.is_active else "🔴 Деактивирован"
|
||||||
password_str = f"🔒 {test.password}" if test.password else "🔓 Без пароля"
|
password_str = f"🔒 {test.password}" if test.password else "🔓 Без пароля"
|
||||||
attempts_str = f"🔄 {test.attempts}" if test.attempts else "♾️ Без ограничений"
|
attempts_str = f"🔄 {test.attempts}" if test.attempts else "♾️ Без ограничений"
|
||||||
expires_str = test.expires_at.strftime("%d.%m.%Y %H:%M") if test.expires_at else "♾️ Без срока"
|
expires_str = f"📅 {test.expires_at.strftime('%d.%m.%Y %H:%M')}" if test.expires_at else "📅 Без срока"
|
||||||
group_str = f"🎓 Группа {test.for_group}" if test.for_group else "👥 Для всех"
|
group_str = f"🎓 Группа {test.for_group}" if test.for_group else "👥 Для всех"
|
||||||
|
|
||||||
test_info = (
|
test_info = (
|
||||||
f"<b>📝 Информация о тесте</b>\n\n"
|
f"<b>📝 Информация о тесте</b>\n\n"
|
||||||
f"<b>Название:</b> {test.title}\n"
|
f"<b>Название:</b>\n<blockquote>{test.title}</blockquote>\n"
|
||||||
f"<b>Описание:</b> {test.description or '—'}\n\n"
|
f"<b>Описание:</b>\n<blockquote>{test.description or '—'}</blockquote>\n\n"
|
||||||
f"<b>Статус:</b> {status}\n"
|
f"<b>Статус:</b> {status}\n"
|
||||||
f"<b>Вопросов:</b> {questions_count}\n"
|
f"<b>Вопросов:</b> {questions_count}\n"
|
||||||
f"{password_str}\n"
|
f"<b>Пароль:</b> {password_str}\n"
|
||||||
f"<b>Попыток:</b> {attempts_str}\n"
|
f"<b>Попытки:</b> {attempts_str}\n"
|
||||||
f"{expires_str}\n"
|
f"<b>Срок:</b> {expires_str}\n"
|
||||||
f"{group_str}\n\n"
|
f"<b>Группа:</b> {group_str}\n\n"
|
||||||
f"<b>Создан:</b> {test.created_at.strftime('%d.%m.%Y %H:%M') if test.created_at else '—'}"
|
f"<b>Создан:</b> {test.created_at.strftime('%d.%m.%Y %H:%M') if test.created_at else '—'}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -161,6 +161,18 @@ async def qr_media_selector(data: dict, widget, manager: DialogManager):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def on_edit_menu(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
|
await manager.switch_to(AdminTestsSG.edit_menu)
|
||||||
|
|
||||||
|
|
||||||
|
async def on_back_to_detail(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
|
await manager.switch_to(AdminTestsSG.test_detail)
|
||||||
|
|
||||||
|
|
||||||
|
async def on_back_to_edit_menu(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
|
await manager.switch_to(AdminTestsSG.edit_menu)
|
||||||
|
|
||||||
|
|
||||||
async def on_edit_password(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
async def on_edit_password(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
await manager.switch_to(AdminTestsSG.edit_password)
|
await manager.switch_to(AdminTestsSG.edit_password)
|
||||||
|
|
||||||
@@ -351,21 +363,29 @@ tests_dialog = Dialog(
|
|||||||
on_click=on_toggle_active
|
on_click=on_toggle_active
|
||||||
),
|
),
|
||||||
Button(Const("🔗 Поделиться"), id="share", on_click=on_share_test),
|
Button(Const("🔗 Поделиться"), id="share", on_click=on_share_test),
|
||||||
Button(Const("🔑 Изменить пароль"), id="edit_password", on_click=on_edit_password),
|
Button(Const("✏️ Изменить"), id="edit_menu", on_click=on_edit_menu),
|
||||||
Button(Const("🔄 Изменить попытки"), id="edit_attempts", on_click=on_edit_attempts),
|
|
||||||
Button(Const("👥 Изменить группу"), id="edit_group", on_click=on_edit_group),
|
|
||||||
Button(Const("📅 Изменить срок"), id="edit_expires", on_click=on_edit_expires),
|
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
||||||
),
|
),
|
||||||
state=AdminTestsSG.test_detail,
|
state=AdminTestsSG.test_detail,
|
||||||
getter=get_test_detail,
|
getter=get_test_detail,
|
||||||
),
|
),
|
||||||
|
Window(
|
||||||
|
Const("<b>✏️ Изменить тест</b>\n\nВыберите, что хотите изменить:"),
|
||||||
|
Column(
|
||||||
|
Button(Const("🔑 Пароль"), id="edit_password", on_click=on_edit_password),
|
||||||
|
Button(Const("🔄 Попытки"), id="edit_attempts", on_click=on_edit_attempts),
|
||||||
|
Button(Const("👥 Группа"), id="edit_group", on_click=on_edit_group),
|
||||||
|
Button(Const("📅 Срок действия"), id="edit_expires", on_click=on_edit_expires),
|
||||||
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_detail),
|
||||||
|
),
|
||||||
|
state=AdminTestsSG.edit_menu,
|
||||||
|
),
|
||||||
Window(
|
Window(
|
||||||
Const("<b>🔑 Изменение пароля</b>\n\n💬 <b>Введите новый пароль</b> или удалите текущий:\n<i>(максимум 255 символов)</i>"),
|
Const("<b>🔑 Изменение пароля</b>\n\n💬 <b>Введите новый пароль</b> или удалите текущий:\n<i>(максимум 255 символов)</i>"),
|
||||||
MessageInput(on_password_input),
|
MessageInput(on_password_input),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Удалить пароль"), id="remove_password", on_click=on_remove_password),
|
Button(Const("🗑 Удалить пароль"), id="remove_password", on_click=on_remove_password),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=AdminTestsSG.edit_password,
|
state=AdminTestsSG.edit_password,
|
||||||
),
|
),
|
||||||
@@ -374,7 +394,7 @@ tests_dialog = Dialog(
|
|||||||
MessageInput(on_attempts_input_edit),
|
MessageInput(on_attempts_input_edit),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Без ограничений"), id="remove_attempts", on_click=on_remove_attempts),
|
Button(Const("🗑 Без ограничений"), id="remove_attempts", on_click=on_remove_attempts),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=AdminTestsSG.edit_attempts,
|
state=AdminTestsSG.edit_attempts,
|
||||||
),
|
),
|
||||||
@@ -394,7 +414,7 @@ tests_dialog = Dialog(
|
|||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Для всех групп"), id="remove_group", on_click=on_remove_group),
|
Button(Const("🗑 Для всех групп"), id="remove_group", on_click=on_remove_group),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=AdminTestsSG.edit_group,
|
state=AdminTestsSG.edit_group,
|
||||||
getter=get_groups_for_edit,
|
getter=get_groups_for_edit,
|
||||||
@@ -404,7 +424,7 @@ tests_dialog = Dialog(
|
|||||||
Calendar(id="calendar", on_click=on_date_selected_for_test),
|
Calendar(id="calendar", on_click=on_date_selected_for_test),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Удалить срок"), id="remove_expires", on_click=on_remove_expires),
|
Button(Const("🗑 Удалить срок"), id="remove_expires", on_click=on_remove_expires),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=AdminTestsSG.edit_expires,
|
state=AdminTestsSG.edit_expires,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class CreatorTestsSG(StatesGroup):
|
|||||||
tests_list = State()
|
tests_list = State()
|
||||||
test_detail = State()
|
test_detail = State()
|
||||||
share_test = State()
|
share_test = State()
|
||||||
|
edit_menu = State()
|
||||||
edit_password = State()
|
edit_password = State()
|
||||||
edit_attempts = State()
|
edit_attempts = State()
|
||||||
edit_group = State()
|
edit_group = State()
|
||||||
|
|||||||
@@ -69,19 +69,19 @@ async def get_test_detail(test_dao: FromDishka[TestDAO], test_repo: FromDishka[T
|
|||||||
status = "🟢 Активен" if test.is_active else "🔴 Деактивирован"
|
status = "🟢 Активен" if test.is_active else "🔴 Деактивирован"
|
||||||
password_str = f"🔒 {test.password}" if test.password else "🔓 Без пароля"
|
password_str = f"🔒 {test.password}" if test.password else "🔓 Без пароля"
|
||||||
attempts_str = f"🔄 {test.attempts}" if test.attempts else "♾️ Без ограничений"
|
attempts_str = f"🔄 {test.attempts}" if test.attempts else "♾️ Без ограничений"
|
||||||
expires_str = test.expires_at.strftime("%d.%m.%Y %H:%M") if test.expires_at else "♾️ Без срока"
|
expires_str = f"📅 {test.expires_at.strftime('%d.%m.%Y %H:%M')}" if test.expires_at else "📅 Без срока"
|
||||||
group_str = f"🎓 Группа {test.for_group}" if test.for_group else "👥 Для всех"
|
group_str = f"🎓 Группа {test.for_group}" if test.for_group else "👥 Для всех"
|
||||||
|
|
||||||
test_info = (
|
test_info = (
|
||||||
f"<b>📝 Информация о тесте</b>\n\n"
|
f"<b>📝 Информация о тесте</b>\n\n"
|
||||||
f"<b>Название:</b> {test.title}\n"
|
f"<b>Название:</b>\n<blockquote>{test.title}</blockquote>\n"
|
||||||
f"<b>Описание:</b> {test.description or '—'}\n\n"
|
f"<b>Описание:</b>\n<blockquote>{test.description or '—'}</blockquote>\n\n"
|
||||||
f"<b>Статус:</b> {status}\n"
|
f"<b>Статус:</b> {status}\n"
|
||||||
f"<b>Вопросов:</b> {questions_count}\n"
|
f"<b>Вопросов:</b> {questions_count}\n"
|
||||||
f"{password_str}\n"
|
f"<b>Пароль:</b> {password_str}\n"
|
||||||
f"<b>Попыток:</b> {attempts_str}\n"
|
f"<b>Попытки:</b> {attempts_str}\n"
|
||||||
f"{expires_str}\n"
|
f"<b>Срок:</b> {expires_str}\n"
|
||||||
f"{group_str}\n\n"
|
f"<b>Группа:</b> {group_str}\n\n"
|
||||||
f"<b>Создан:</b> {test.created_at.strftime('%d.%m.%Y %H:%M') if test.created_at else '—'}"
|
f"<b>Создан:</b> {test.created_at.strftime('%d.%m.%Y %H:%M') if test.created_at else '—'}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -147,6 +147,18 @@ async def on_share_test(_callback: CallbackQuery, _button: Button, manager: Dial
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def on_edit_menu(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
|
await manager.switch_to(CreatorTestsSG.edit_menu)
|
||||||
|
|
||||||
|
|
||||||
|
async def on_back_to_detail(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
|
await manager.switch_to(CreatorTestsSG.test_detail)
|
||||||
|
|
||||||
|
|
||||||
|
async def on_back_to_edit_menu(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
|
await manager.switch_to(CreatorTestsSG.edit_menu)
|
||||||
|
|
||||||
|
|
||||||
async def on_edit_password(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
async def on_edit_password(_callback: CallbackQuery, _button: Button, manager: DialogManager):
|
||||||
await manager.switch_to(CreatorTestsSG.edit_password)
|
await manager.switch_to(CreatorTestsSG.edit_password)
|
||||||
|
|
||||||
@@ -337,21 +349,29 @@ tests_dialog = Dialog(
|
|||||||
on_click=on_toggle_active
|
on_click=on_toggle_active
|
||||||
),
|
),
|
||||||
Button(Const("🔗 Поделиться"), id="share", on_click=on_share_test),
|
Button(Const("🔗 Поделиться"), id="share", on_click=on_share_test),
|
||||||
Button(Const("🔑 Изменить пароль"), id="edit_password", on_click=on_edit_password),
|
Button(Const("✏️ Изменить"), id="edit_menu", on_click=on_edit_menu),
|
||||||
Button(Const("🔄 Изменить попытки"), id="edit_attempts", on_click=on_edit_attempts),
|
|
||||||
Button(Const("👥 Изменить группу"), id="edit_group", on_click=on_edit_group),
|
|
||||||
Button(Const("📅 Изменить срок"), id="edit_expires", on_click=on_edit_expires),
|
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
||||||
),
|
),
|
||||||
state=CreatorTestsSG.test_detail,
|
state=CreatorTestsSG.test_detail,
|
||||||
getter=get_test_detail,
|
getter=get_test_detail,
|
||||||
),
|
),
|
||||||
Window(
|
Window(
|
||||||
Const("<b>� Измеенение пароля</b>\n\n� <b>СВведите новый пароль</b> или удалите текущий:\n<i>(максимум 255 символов)</i>"),
|
Const("<b>✏️ Изменить тест</b>\n\nВыберите, что хотите изменить:"),
|
||||||
|
Column(
|
||||||
|
Button(Const("🔑 Пароль"), id="edit_password", on_click=on_edit_password),
|
||||||
|
Button(Const("🔄 Попытки"), id="edit_attempts", on_click=on_edit_attempts),
|
||||||
|
Button(Const("👥 Группа"), id="edit_group", on_click=on_edit_group),
|
||||||
|
Button(Const("📅 Срок действия"), id="edit_expires", on_click=on_edit_expires),
|
||||||
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_detail),
|
||||||
|
),
|
||||||
|
state=CreatorTestsSG.edit_menu,
|
||||||
|
),
|
||||||
|
Window(
|
||||||
|
Const("<b>🔑 Изменение пароля</b>\n\n💬 <b>Введите новый пароль</b> или удалите текущий:\n<i>(максимум 255 символов)</i>"),
|
||||||
MessageInput(on_password_input),
|
MessageInput(on_password_input),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Удалить пароль"), id="remove_password", on_click=on_remove_password),
|
Button(Const("🗑 Удалить пароль"), id="remove_password", on_click=on_remove_password),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=CreatorTestsSG.edit_password,
|
state=CreatorTestsSG.edit_password,
|
||||||
),
|
),
|
||||||
@@ -360,7 +380,7 @@ tests_dialog = Dialog(
|
|||||||
MessageInput(on_attempts_input_edit),
|
MessageInput(on_attempts_input_edit),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Без ограничений"), id="remove_attempts", on_click=on_remove_attempts),
|
Button(Const("🗑 Без ограничений"), id="remove_attempts", on_click=on_remove_attempts),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=CreatorTestsSG.edit_attempts,
|
state=CreatorTestsSG.edit_attempts,
|
||||||
),
|
),
|
||||||
@@ -380,7 +400,7 @@ tests_dialog = Dialog(
|
|||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Для всех групп"), id="remove_group", on_click=on_remove_group),
|
Button(Const("🗑 Для всех групп"), id="remove_group", on_click=on_remove_group),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=CreatorTestsSG.edit_group,
|
state=CreatorTestsSG.edit_group,
|
||||||
getter=get_groups_for_edit,
|
getter=get_groups_for_edit,
|
||||||
@@ -390,7 +410,7 @@ tests_dialog = Dialog(
|
|||||||
Calendar(id="calendar", on_click=on_date_selected_for_test),
|
Calendar(id="calendar", on_click=on_date_selected_for_test),
|
||||||
Column(
|
Column(
|
||||||
Button(Const("🗑 Удалить срок"), id="remove_expires", on_click=on_remove_expires),
|
Button(Const("🗑 Удалить срок"), id="remove_expires", on_click=on_remove_expires),
|
||||||
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_list),
|
Button(Const("◀️ Назад"), id="back", on_click=on_back_to_edit_menu),
|
||||||
),
|
),
|
||||||
state=CreatorTestsSG.edit_expires,
|
state=CreatorTestsSG.edit_expires,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user