def PromoteUser(user_id, sections): user = User.get(id=user_id) user.state = 'stp_initial' user.save() stp = Stp.get_or_create(user=user, staff_id=1, is_active=True)[0] stp.save() [ StpSection.get_or_create(stp=stp, section=section, importance=1) for section in sections ]
def promote_to_stp(user): tb = telebot.TeleBot(config.token) user = User.get(id=user) user.state = 'stp_main_menu' user.save() stp = Stp.get_or_create(user=user)[0] stp.is_active = True stp.save() try: keyboard = generate_custom_keyboard( types.ReplyKeyboardMarkup, buttons=[ ["Список запросов"], ["Мои активные запросы"], # ["Мои завершенные запросы"] ]) tb.send_message( user.telegram_chat_id, "Вы были переведены в раздел СТП, команды находятся под полем ввода", reply_markup=keyboard) except Exception as e: print("Cant promote to stp, reason: %s" % e) return redirect(url_for('stp.edit_view', id=stp.id))