refactored database model

This commit is contained in:
Hosein
2026-01-05 14:30:25 +03:30
parent 8680778584
commit 4b5b24c97c
4 changed files with 236 additions and 558 deletions
+2 -1
View File
@@ -3,7 +3,8 @@ from database.models import Categories
from bot.handlers.start import startMarkup
from bot.utils.crud_helpers import create_entity_markup
# TODO: Add Option for showing courses with specific tags.
# TODO: Add Option for showing parent categories when creating a new category.
# TODO: Show Some of the courses of a Category.
def register(bot: TeleBot):
+2 -2
View File
@@ -41,7 +41,7 @@ def register(bot: TeleBot):
@bot.callback_query_handler(func=lambda call: call.data.startswith('teacher_'))
def show_teacher_details(call):
teacher_id = call.data.split('_')[1]
teacher = Teachers.getTeachertById(teacher_id)
teacher = Teachers.getTeacherById(teacher_id)
if teacher:
details = format_teacher_info(teacher)
@@ -101,7 +101,7 @@ def register(bot: TeleBot):
@bot.callback_query_handler(func=lambda call: call.data.startswith('edit_teacher_'))
def start_teacher_editing(call):
teacher_id = call.data.split('_')[2]
teacher = Teachers.getTeachertById(teacher_id)
teacher = Teachers.getTeacherById(teacher_id)
if not teacher:
bot.send_message(call.message.chat.id, "Teacher not found.")
+7 -3
View File
@@ -1,11 +1,11 @@
import logging
from telebot import types
from telebot import types, TeleBot
from database.models import Tags
logger = logging.getLogger(__name__)
def register(bot):
def register(bot: TeleBot):
@bot.message_handler(func=lambda message: message.text == "Show Tags")
def get_tags(message):
try:
@@ -25,7 +25,11 @@ def register(bot):
bot.send_message(
message.chat.id, "Here is the data:", reply_markup=markup)
else:
bot.reply_to(message, "No data found.")
markup = types.InlineKeyboardMarkup(row_width=2)
markup.add(types.InlineKeyboardButton(
" Create New Tag", callback_data="create_tag"))
bot.reply_to(message, "No data found.", markup=markup)
except Exception as e:
logger.error(f"Error in 'Show Tags' handler: {e}")
bot.reply_to(message, "Sorry, an error occurred.")