def paginated_resumes(update, context): query = update.callback_query language = context.user_data['user'].get('language') page = query.data.split(':')[1] if page == 'back': user_id = context.user_data['user'].get('id') user_vacations = users.get_user_vacations(user_id) list_message = strings.get_string('vacations.resumes.select', language) list_keyboard = keyboards.get_vacations_keyboard( user_vacations, language, include_create_button=False) query.edit_message_text(text=list_message, reply_markup=list_keyboard) return LIST if int(page) == context.user_data['current_page']: return RESUMES resume = context.user_data['found_resumes'][int(page) - 1] user = users.user_exists(resume.get('user_id')) resume_message = strings.from_resume(resume, language, for_vacation=True, user=user) resume_keyboard = keyboards.get_list_paginated_keyboard( context.user_data['found_resumes'], language, current_page=int(page)) query.edit_message_text(text=resume_message, reply_markup=resume_keyboard, parse_mode=ParseMode.HTML) context.user_data['current_page'] = int(page) return RESUMES
def vacations_list(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END context.user_data['has_action'] = True query = update.callback_query language = context.user_data['user'].get('language') user_id = context.user_data['user'].get('id') user_vacations = users.get_user_vacations(user_id) if len(user_vacations) == 0: empty_message = strings.get_string('vacations.empty_list', language) query.answer(text=empty_message, show_alert=True) del context.user_data['has_action'] return ConversationHandler.END list_message = strings.get_string('vacations.resumes.select', language) list_keyboard = keyboards.get_vacations_keyboard( user_vacations, language, include_create_button=False) context.bot.delete_message(chat_id=user_id, message_id=query.message.message_id) context.bot.send_message(chat_id=user_id, text=list_message, reply_markup=list_keyboard, parse_mode=ParseMode.HTML) return LIST
def vacation_action(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END language = context.user_data['user'].get('language') query = update.callback_query data = query.data if data == 'edit': return edit(update, context) elif data == 'delete': return delete(update, context) elif data == 'back': user_id = query.from_user.id user_vacations = users.get_user_vacations(user_id) keyboard = keyboards.get_vacations_keyboard(user_vacations, language) message = strings.get_string('vacations.list', language) query.edit_message_text(message, parse_mode=ParseMode.HTML, reply_markup=keyboard) del context.user_data['has_action'] return ConversationHandler.END else: return VACATION_ACTION
def delete(update, context): query = update.callback_query language = context.user_data['user'].get('language') vacations.delete_vacation(context.user_data['editing_vacation'].get('id')) success = strings.get_string('success', language) query.answer(text=success) user_id = query.from_user.id user_vacations = users.get_user_vacations(user_id) keyboard = keyboards.get_vacations_keyboard(user_vacations, language) message = strings.get_string('vacations.list', language) query.edit_message_text(message, parse_mode=ParseMode.HTML, reply_markup=keyboard) del context.user_data['has_action'] return ConversationHandler.END
def user_vacations(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return language = context.user_data['user'].get('language') query = update.callback_query user_id = query.from_user.id vacations = users.get_user_vacations(user_id) keyboard = keyboards.get_vacations_keyboard(vacations, language) message = strings.get_string('vacations.list', language) context.bot.delete_message(chat_id=user_id, message_id=query.message.message_id) context.bot.send_message(chat_id=user_id, text=message, reply_markup=keyboard, parse_mode=ParseMode.HTML)