Exemplo n.º 1
0
def resume_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_resumes = users.get_user_resumes(user_id)
        keyboard = keyboards.get_resumes_keyboard(user_resumes, language)
        message = strings.get_string('resumes.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 RESUME_ACTION
Exemplo n.º 2
0
def paginated_vacations(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_resumes = users.get_user_resumes(user_id)
        list_message = strings.get_string('resumes.vacations.select', language)
        list_keyboard = keyboards.get_resumes_keyboard(
            user_resumes, 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 VACATIONS
    vacation = context.user_data['found_vacations'][int(page) - 1]
    user = users.user_exists(vacation.get('user_id'))
    vacation_message = strings.from_vacation(vacation,
                                             language,
                                             for_resume=True,
                                             user=user)
    vacations_keyboard = keyboards.get_list_paginated_keyboard(
        context.user_data['found_vacations'], language, current_page=int(page))
    query.edit_message_text(text=vacation_message,
                            reply_markup=vacations_keyboard,
                            parse_mode=ParseMode.HTML)
    context.user_data['current_page'] = int(page)
    return VACATIONS
Exemplo n.º 3
0
def resumes_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_resumes = users.get_user_resumes(user_id)
    if len(user_resumes) == 0:
        empty_message = strings.get_string('resumes.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('resumes.vacations.select', language)
    list_keyboard = keyboards.get_resumes_keyboard(user_resumes,
                                                   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
Exemplo n.º 4
0
def delete(update, context):
    query = update.callback_query
    language = context.user_data['user'].get('language')
    resumes.delete_resume(context.user_data['editing_resume'].get('id'))
    success = strings.get_string('success', language)
    query.answer(text=success)
    user_id = query.from_user.id
    user_resumes = users.get_user_resumes(user_id)
    keyboard = keyboards.get_resumes_keyboard(user_resumes, language)
    message = strings.get_string('resumes.list', language)
    query.edit_message_text(message,
                            parse_mode=ParseMode.HTML,
                            reply_markup=keyboard)
    del context.user_data['has_action']
    return ConversationHandler.END
Exemplo n.º 5
0
def user_resumes(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
    query.answer()
    user_id = query.from_user.id
    resumes = users.get_user_resumes(user_id)
    keyboard = keyboards.get_resumes_keyboard(resumes, language)
    message = strings.get_string('resumes.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)