add dialog for events_list
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from aiogram import Router
|
||||
|
||||
from .events.dialogs import events_dialog
|
||||
from .profile.dialogs import profile_dialog
|
||||
from .start.dialogs import start_dialog
|
||||
|
||||
dialogs_router = Router(name="dialogs")
|
||||
dialogs_router.include_router(start_dialog)
|
||||
dialogs_router.include_router(events_dialog)
|
||||
dialogs_router.include_router(profile_dialog)
|
||||
|
||||
23
app/bot/dialogs/flows/events/dialogs.py
Normal file
23
app/bot/dialogs/flows/events/dialogs.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from aiogram_dialog import Dialog, Window
|
||||
from aiogram_dialog.widgets.kbd import Column, Select
|
||||
from aiogram_dialog.widgets.text import Const, Format
|
||||
|
||||
from .getters import events_getter
|
||||
from .states import EventsSG
|
||||
|
||||
events_dialog = Dialog(
|
||||
Window(
|
||||
Const("События"),
|
||||
Column(
|
||||
Select(
|
||||
Format("{item}"),
|
||||
id="categ",
|
||||
item_id_getter=lambda x: x,
|
||||
items="events",
|
||||
)
|
||||
),
|
||||
getter=events_getter,
|
||||
state=EventsSG.events_list,
|
||||
),
|
||||
# Window(state=EventsSG.event),
|
||||
)
|
||||
6
app/bot/dialogs/flows/events/getters.py
Normal file
6
app/bot/dialogs/flows/events/getters.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from aiogram.types import User
|
||||
from aiogram_dialog import DialogManager
|
||||
|
||||
|
||||
async def events_getter(dialog_manager: DialogManager, event_from_user: User, **kwargs) -> dict[str, str]:
|
||||
return {"events": ["ev1", "ev2", "ev3"]}
|
||||
6
app/bot/dialogs/flows/events/states.py
Normal file
6
app/bot/dialogs/flows/events/states.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
|
||||
|
||||
class EventsSG(StatesGroup):
|
||||
events_list = State()
|
||||
event = State()
|
||||
@@ -2,6 +2,7 @@ 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.events.dialogs import EventsSG
|
||||
from app.bot.dialogs.flows.profile.dialogs import ProfileSG
|
||||
from app.bot.dialogs.widgets.getters import is_admin, username_getter
|
||||
|
||||
@@ -10,7 +11,7 @@ from .states import StartSG
|
||||
start_dialog = Dialog(
|
||||
Window(
|
||||
Format("Привет, {username}"),
|
||||
Button(Const("события"), id="events"),
|
||||
Start(Const("события"), id="events", state=EventsSG.events_list),
|
||||
Button(Const("создать событие"), id="create_event", when="is_admin"),
|
||||
Start(Const("профиль"), id="profile", state=ProfileSG.profile),
|
||||
getter=[username_getter, is_admin],
|
||||
|
||||
Reference in New Issue
Block a user