🧹 Конфиг: услуги, мастера и время вынесены в config.py
- SERVICES, MASTERS, TIME_SLOTS в config.py - Клавиатуры services.py, masters.py, time_slots.py берут данные из config - booking.py импортирует services/masters из config вместо хардкода - time_slots отображает занятые слоты как ❌, свободные как ✅
This commit is contained in:
+16
-38
@@ -1,41 +1,19 @@
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from app.config import TIME_SLOTS
|
||||
|
||||
|
||||
def get_time_keyboard(
|
||||
busy_times=None
|
||||
):
|
||||
|
||||
if busy_times is None:
|
||||
busy_times = []
|
||||
|
||||
times = [
|
||||
"10:00",
|
||||
"11:00",
|
||||
"12:00",
|
||||
"13:00",
|
||||
"14:00",
|
||||
"15:00",
|
||||
"16:00",
|
||||
"17:00"
|
||||
]
|
||||
|
||||
def get_time_keyboard(busy_times):
|
||||
buttons = []
|
||||
|
||||
for time in times:
|
||||
|
||||
if time in busy_times:
|
||||
continue
|
||||
|
||||
buttons.append(
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=time,
|
||||
callback_data=f"time_{time}"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
return InlineKeyboardMarkup(
|
||||
inline_keyboard=buttons
|
||||
)
|
||||
row = []
|
||||
for slot in TIME_SLOTS:
|
||||
if slot in busy_times:
|
||||
label = f❌ {slot}
|
||||
else:
|
||||
label = f✅ {slot}
|
||||
row.append(InlineKeyboardButton(text=label, callback_data=ftime_{slot}))
|
||||
if len(row) == 3:
|
||||
buttons.append(row)
|
||||
row = []
|
||||
if row:
|
||||
buttons.append(row)
|
||||
return InlineKeyboardMarkup(inline_keyboard=buttons)
|
||||
|
||||
Reference in New Issue
Block a user