Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feedback feature, add make #17

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
DATABASE_URL=<'DATABASE URL'>
TELEGRAM_TOKEN=<'TELEGRAM TOKEN'>
TELEGRAM_CHAT_IDS=<'TELEGRAM CHAT IDS'>

BOT_TOKEN=<'BOT TOKEN'>
TELEGRAM_CHAT_IDS=<'TELEGRAM CHAT IDS'>

DATABASE_URL=<'DATABASE URL'>
POSTGRES_USER=<'DB OWNER'>
POSTGRES_PASSWORD=<'PASSWORD'>
Expand Down
1 change: 1 addition & 0 deletions app/admin/filters/filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from aiogram.filters import Filter
from aiogram import Bot, types

# from settings import admin_list
from const import admin_list

Expand Down
4 changes: 1 addition & 3 deletions app/admin/handlers/admin_handlers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ async def user_callback_request_data(


@admin_main_router.callback_query(UserState.close_case, F.data)
async def close_case(
callback: CallbackQuery, state: FSMContext, session: AsyncSession
):
async def close_case(callback: CallbackQuery, state: FSMContext, session: AsyncSession):
"""Закрыть заявку на обратный звонок."""

user = await user_crud.get(callback.data, session)
Expand Down
33 changes: 9 additions & 24 deletions app/admin/handlers/admin_handlers/admin_about_company_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
get_inline_confirmation_keyboard,
get_inline_keyboard,
)

# from settings import MAIN_MENU_OPTIONS

MAIN_MENU_OPTIONS = {
Expand Down Expand Up @@ -59,9 +60,7 @@ async def add_info_name(message: Message, state: FSMContext):


@about_router.message(AddAboutInfo.url, F.text)
async def add_about_data(
message: Message, state: FSMContext, session: AsyncSession
):
async def add_about_data(message: Message, state: FSMContext, session: AsyncSession):
await state.update_data(url=message.text)
data = await state.get_data()
await company_info_crud.create(data, session)
Expand All @@ -80,9 +79,7 @@ async def about_info_to_delete(
info_list = [info.name for info in about_data]
await callback.message.answer(
"Какую информацию вы хотите удалить?",
reply_markup=await get_inline_keyboard(
info_list, previous_menu=PREVIOUS_MENU
),
reply_markup=await get_inline_keyboard(info_list, previous_menu=PREVIOUS_MENU),
)
await state.set_state(DeleteAboutInfo.name)

Expand All @@ -91,9 +88,7 @@ async def about_info_to_delete(
async def confirm_delete_info(
callback: CallbackQuery, state: FSMContext, session: AsyncSession
):
about_data = await company_info_crud.get_by_about_name(
callback.data, session
)
about_data = await company_info_crud.get_by_about_name(callback.data, session)
await callback.message.edit_text(
f"Вы уверены, что хотите удалить эту информацию?\n\n {about_data.name}",
reply_markup=await get_inline_confirmation_keyboard(
Expand All @@ -107,9 +102,7 @@ async def confirm_delete_info(
async def delete_about_info(
callback: CallbackQuery, state: FSMContext, session: AsyncSession
):
about_data = await company_info_crud.get_by_about_name(
callback.data, session
)
about_data = await company_info_crud.get_by_about_name(callback.data, session)
await company_info_crud.remove(about_data, session)
await callback.message.edit_text(
"Информация удалена!",
Expand All @@ -126,9 +119,7 @@ async def about_info_to_update(
info_list = [info.name for info in about_data]
await callback.message.edit_text(
"Какую информацию вы хотите отредактировать?",
reply_markup=await get_inline_keyboard(
info_list, previous_menu=PREVIOUS_MENU
),
reply_markup=await get_inline_keyboard(info_list, previous_menu=PREVIOUS_MENU),
)
await state.set_state(UpdateAboutInfo.select)

Expand All @@ -151,9 +142,7 @@ async def update_info_choise(callback: CallbackQuery, state: FSMContext):
)


@about_router.callback_query(
UpdateAboutInfo.select, F.data == "Название ссылки"
)
@about_router.callback_query(UpdateAboutInfo.select, F.data == "Название ссылки")
async def about_name_update(
callback: CallbackQuery, state: FSMContext, session: AsyncSession
):
Expand All @@ -171,19 +160,15 @@ async def about_url_update(
):
about_name_data = await state.get_data()
about_name_text = about_name_data.get("select")
about_info = await company_info_crud.get_by_about_name(
about_name_text, session
)
about_info = await company_info_crud.get_by_about_name(about_name_text, session)
await callback.message.answer(
f"Сейчас у ссылки такой адрес:\n\n {about_info.url}\n\n Введите новое название"
)
await state.set_state(UpdateAboutInfo.url)


@about_router.message(or_f(UpdateAboutInfo.name, UpdateAboutInfo.url), F.text)
async def update_about_info(
message: Message, state: FSMContext, session: AsyncSession
):
async def update_about_info(message: Message, state: FSMContext, session: AsyncSession):
current_state = await state.get_state()
old_data = await state.get_data()
old_about_data = await company_info_crud.get_by_about_name(
Expand Down
21 changes: 6 additions & 15 deletions app/admin/handlers/admin_handlers/admin_category_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
get_inline_confirmation_keyboard,
get_inline_keyboard,
)

# from settings import MAIN_MENU_OPTIONS, admin_list
from const import admin_list

Expand Down Expand Up @@ -163,9 +164,7 @@ async def add_product_category_data(
)


@category_router.message(
or_f(AddCategory.media, UpdateCategory.media), F.photo
)
@category_router.message(or_f(AddCategory.media, UpdateCategory.media), F.photo)
async def add_media_description(message: Message, state: FSMContext):
"""Добавить описание к картинке."""
await state.update_data(media=message.photo[-1].file_id)
Expand Down Expand Up @@ -204,9 +203,7 @@ async def product_to_delete(
callback: CallbackQuery, state: FSMContext, session: AsyncSession
):
"""Выбор продукта на удаление."""
categories = [
category.name for category in await get_category_list(state, session)
]
categories = [category.name for category in await get_category_list(state, session)]
await callback.message.edit_text(
"Какой проект вы хотите удалить?",
reply_markup=await get_inline_keyboard(
Expand Down Expand Up @@ -250,9 +247,7 @@ async def product_to_update(
callback: CallbackQuery, state: FSMContext, session: AsyncSession
):
"""Выбор продукта для редактирования."""
categories = [
category.name for category in await get_category_list(state, session)
]
categories = [category.name for category in await get_category_list(state, session)]
await callback.message.edit_text(
"Какую услугу вы хотите отредактировать?",
reply_markup=await get_inline_keyboard(
Expand All @@ -266,9 +261,7 @@ async def product_to_update(
UpdateCategory.select,
and_f(F.data != "Название", F.data != "Содержание"),
)
async def update_portfolio_project_choise(
callback: CallbackQuery, state: FSMContext
):
async def update_portfolio_project_choise(callback: CallbackQuery, state: FSMContext):
"""Выбор поля для редактирования."""
await state.update_data(select=callback.data)
await callback.message.edit_text(
Expand Down Expand Up @@ -332,9 +325,7 @@ async def about_url_update(
F.photo,
),
)
async def update_about_info(
message: Message, state: FSMContext, session: AsyncSession
):
async def update_about_info(message: Message, state: FSMContext, session: AsyncSession):
"""Внести изменения продукта в БД."""
current_state = await state.get_state()
old_data = await state.get_data()
Expand Down
29 changes: 8 additions & 21 deletions app/admin/handlers/admin_handlers/admin_info_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
get_inline_confirmation_keyboard,
get_inline_keyboard,
)

# from settings import SUPPORT_OPTIONS
from sqlalchemy.ext.asyncio import AsyncSession
from aiogram.fsm.state import State, StatesGroup
Expand Down Expand Up @@ -67,9 +68,7 @@ async def get_question_list(question_type: str, session: AsyncSession):
async def add_question(callback: CallbackQuery, state: FSMContext):
current_state = await state.get_state()
await state.set_state(AddQuestion.question_type)
await state.update_data(
question_type=await set_question_type(current_state)
)
await state.update_data(question_type=await set_question_type(current_state))
await callback.message.answer("Введите текст нового вопрос")
await state.set_state(AddQuestion.question)

Expand All @@ -93,9 +92,7 @@ async def add_question_answer(
await info_crud.create(data, session=session)
await message.answer(
"Вопрос добавлен!",
reply_markup=await get_inline_keyboard(
previous_menu=data.get("question_type")
),
reply_markup=await get_inline_keyboard(previous_menu=data.get("question_type")),
)
await state.clear()

Expand All @@ -108,9 +105,7 @@ async def question_to_delete(
):
current_state = await state.get_state()
await state.set_state(DeleteQuestion.question_type)
await state.update_data(
question_type=await set_question_type(current_state)
)
await state.update_data(question_type=await set_question_type(current_state))
question_type = (await state.get_data()).get("question_type")
question_list = await get_question_list(question_type, session)
await callback.message.edit_text(
Expand Down Expand Up @@ -145,9 +140,7 @@ async def delete_question(
await info_crud.remove(question, session)
await callback.message.edit_text(
"Вопрос удален!",
reply_markup=await get_inline_keyboard(
previous_menu=question.question_type
),
reply_markup=await get_inline_keyboard(previous_menu=question.question_type),
)


Expand All @@ -160,9 +153,7 @@ async def update_question(
):
current_state = await state.get_state()
await state.set_state(UpdateQuestion.question_type)
await state.update_data(
question_type=await set_question_type(current_state)
)
await state.update_data(question_type=await set_question_type(current_state))
question_type = (await state.get_data()).get("question_type")
question_list = await get_question_list(question_type, session)
await callback.message.edit_text(
Expand Down Expand Up @@ -208,17 +199,13 @@ async def update_question_answer(
await state.set_state(UpdateQuestion.answer)


@info_router.message(
or_f(UpdateQuestion.confirm, UpdateQuestion.answer), F.text
)
@info_router.message(or_f(UpdateQuestion.confirm, UpdateQuestion.answer), F.text)
async def update_question_data(
message: Message, state: FSMContext, session: AsyncSession
):
current_state = await state.get_state()
old_data = await state.get_data()
question = await info_crud.get_by_question_text(
old_data.get("question"), session
)
question = await info_crud.get_by_question_text(old_data.get("question"), session)

if current_state == UpdateQuestion.confirm:
await state.update_data(question=message.text)
Expand Down
Loading
Loading