diff --git a/app/bot/dialogs/flows/__init__.py b/app/bot/dialogs/flows/__init__.py index f5d7585..3adb1f0 100644 --- a/app/bot/dialogs/flows/__init__.py +++ b/app/bot/dialogs/flows/__init__.py @@ -1,8 +1,10 @@ from aiogram import Router from .admin import admin_router +from .common import common_router from .user import user_router dialogs_router = Router(name="dialogs") dialogs_router.include_router(admin_router) dialogs_router.include_router(user_router) +dialogs_router.include_router(common_router) diff --git a/app/bot/dialogs/flows/admin/start/dialogs.py b/app/bot/dialogs/flows/admin/start/dialogs.py index 3f6cd0d..e1b0052 100644 --- a/app/bot/dialogs/flows/admin/start/dialogs.py +++ b/app/bot/dialogs/flows/admin/start/dialogs.py @@ -1,13 +1,18 @@ from aiogram_dialog import Dialog, Window -from aiogram_dialog.widgets.text import Format +from aiogram_dialog.widgets.kbd import Button, Start +from aiogram_dialog.widgets.text import Const, Format +from app.bot.dialogs.flows.common.profile.dialogs import ProfileSG from app.bot.dialogs.widgets.getters import username_getter from .states import AdminStartSG admin_start_dialog = Dialog( Window( - Format("Hello, {username}"), + Format("Привет, {username}"), + Button(Const("события"), id="events"), + Button(Const("создать событие"), when="is_admin"), + Start(Const("профиль"), id="profile", state=ProfileSG.profile), getter=username_getter, state=AdminStartSG.start, ) diff --git a/app/bot/dialogs/flows/common/__init__.py b/app/bot/dialogs/flows/common/__init__.py new file mode 100644 index 0000000..9ac55eb --- /dev/null +++ b/app/bot/dialogs/flows/common/__init__.py @@ -0,0 +1,7 @@ +from aiogram import Router + +from .profile.dialogs import user_profile_dialog + +common_router = Router(name="common dialogs") + +common_router.include_router(user_profile_dialog) diff --git a/app/bot/dialogs/flows/user/profile/dialogs.py b/app/bot/dialogs/flows/common/profile/dialogs.py similarity index 60% rename from app/bot/dialogs/flows/user/profile/dialogs.py rename to app/bot/dialogs/flows/common/profile/dialogs.py index f9dc23d..0e4b5f3 100644 --- a/app/bot/dialogs/flows/user/profile/dialogs.py +++ b/app/bot/dialogs/flows/common/profile/dialogs.py @@ -1,9 +1,9 @@ from aiogram_dialog import Dialog, Window from aiogram_dialog.widgets.input import TextInput -from aiogram_dialog.widgets.kbd import Back, Cancel, SwitchTo +from aiogram_dialog.widgets.kbd import Cancel, SwitchTo from aiogram_dialog.widgets.text import Const, Format -from .states import UserProfileSG +from .states import ProfileSG user_profile_dialog = Dialog( Window( @@ -13,26 +13,26 @@ user_profile_dialog = Dialog( SwitchTo( Const("изменить имя"), id="change_name", - state=UserProfileSG.change_name, + state=ProfileSG.change_name, ), SwitchTo( Const("изменить телефон"), id="change_phone", - state=UserProfileSG.change_phone, + state=ProfileSG.change_phone, ), Cancel(Const("назад")), - state=UserProfileSG.profile, + state=ProfileSG.profile, ), Window( Const("Введите имя"), - SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile), + SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile), TextInput(id="name_input"), - state=UserProfileSG.change_name, + state=ProfileSG.change_name, ), Window( Const("Введите телефон"), - SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile), + SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile), TextInput(id="phone_input"), - state=UserProfileSG.change_phone, + state=ProfileSG.change_phone, ), ) diff --git a/app/bot/dialogs/flows/user/profile/states.py b/app/bot/dialogs/flows/common/profile/states.py similarity index 83% rename from app/bot/dialogs/flows/user/profile/states.py rename to app/bot/dialogs/flows/common/profile/states.py index 3d69640..74ec22e 100644 --- a/app/bot/dialogs/flows/user/profile/states.py +++ b/app/bot/dialogs/flows/common/profile/states.py @@ -1,7 +1,7 @@ from aiogram.fsm.state import State, StatesGroup -class UserProfileSG(StatesGroup): +class ProfileSG(StatesGroup): profile = State() change_name = State() input_name = State() diff --git a/app/bot/dialogs/flows/user/__init__.py b/app/bot/dialogs/flows/user/__init__.py index 88ab126..893c8b0 100644 --- a/app/bot/dialogs/flows/user/__init__.py +++ b/app/bot/dialogs/flows/user/__init__.py @@ -1,8 +1,6 @@ from aiogram import Router -from .profile.dialogs import user_profile_dialog from .start.dialogs import user_start_dialog user_router = Router(name="user dialogs") user_router.include_router(user_start_dialog) -user_router.include_router(user_profile_dialog) diff --git a/app/bot/dialogs/flows/user/start/dialogs.py b/app/bot/dialogs/flows/user/start/dialogs.py index 029e6d0..11848d4 100644 --- a/app/bot/dialogs/flows/user/start/dialogs.py +++ b/app/bot/dialogs/flows/user/start/dialogs.py @@ -2,16 +2,16 @@ from aiogram_dialog import Dialog, Window from aiogram_dialog.widgets.kbd import Button, Start from aiogram_dialog.widgets.text import Const, Format -from app.bot.dialogs.flows.user.profile.dialogs import UserProfileSG +from app.bot.dialogs.flows.common.profile.dialogs import ProfileSG from app.bot.dialogs.widgets.getters import username_getter from .states import UserStartSG user_start_dialog = Dialog( Window( - Format("Hello, {username}"), - Button(Const("События"), id="events"), - Start(Const("Профиль"), id="profile", state=UserProfileSG.profile), + Format("Привет, {username}"), + Button(Const("события"), id="events"), + Start(Const("профиль"), id="profile", state=ProfileSG.profile), getter=username_getter, state=UserStartSG.start, )