Пример #1
0
async def recieve_resume(message: types.Message, state: FSMContext):
    if message.document.mime_type == 'application/pdf':
        file_id = message.document.file_id
        file_path = settings.resumes_path_base + str(file_id) + '.pdf'
        await bot.download_file_by_id(file_id, file_path)
        text_pdf = parser_from_pdf.extract_text_from_pdf(file_path)
        json_obj = json.dumps(text_pdf)
        async with state.proxy() as s:
            vacancy_id = s['id']
        candidate = Candidate(user=User.get(User.chat_id == message.chat.id),
                              vacancy=Vacancy.get(Vacancy.id == vacancy_id),
                              resume_file_id=file_id,
                              resume_json=json_obj,
                              status='Резюме обрабатывается')
        candidate.save()
        await message.answer(messages.resume_in_treatment)
        treatment_result = await treatment_resume(candidate.id)
        if treatment_result:
            candidate.status = 'Резюме одобрено'
            candidate.save()
            await message.answer(messages.resume_is_good)
            vacancy = Vacancy.get(Vacancy.id == vacancy_id)
            if vacancy.test_task:
                keyboard = InlineKeyboardMarkup()
                keyboard.add(
                    InlineKeyboardButton(buttons.menu, callback_data='menu'))
                await bot.send_document(message.chat.id,
                                        open(vacancy.test_task, 'rb'),
                                        caption=messages.here_is_task,
                                        reply_markup=keyboard)
                candidate.status = 'Отправлено тестовое задание'
                candidate.save()
                await state.finish()
            else:
                keyboard = InlineKeyboardMarkup()
                keyboard.add(
                    InlineKeyboardButton(buttons.menu, callback_data='menu'))
                await message.answer(messages.there_is_no_task,
                                     reply_markup=keyboard)
                candidate.status = 'Контакты отправлены работодателю'
                candidate.save()
                # resume = json.loads(candidate.resume_json)['info']
                await bot.send_message(
                    candidate.vacancy.creator.chat_id,
                    messages.user_without_task.format(candidate.user.username,
                                                      candidate.vacancy.name))
                await state.finish()
        else:
            candidate.status = 'Резюме отклонено'
            candidate.save()
            await message.answer(messages.resume_is_bad)
            await FindVacancy.id.set()

    else:
        keyboard = InlineKeyboardMarkup()
        keyboard.add(
            InlineKeyboardButton(buttons.back,
                                 callback_data='back_to_find_vacancies'))
        await message.answer(messages.something_wrong, reply_markup=keyboard)
Пример #2
0
async def add_task(query: callback_query, state: FSMContext):
    vacancy_id = int(query.data.split('_')[2])
    vacancy = Vacancy.get(Vacancy.id == vacancy_id)
    keyboard = InlineKeyboardMarkup()
    keyboard.add(
        InlineKeyboardButton(buttons.back, callback_data='vacancy_myback'))
    await AddTaskState.file.set()
    await state.update_data(vacancy_id=vacancy_id)
    await query.message.answer(messages.send_me_task, reply_markup=keyboard)
Пример #3
0
async def add_task_file(message: types.Message, state: FSMContext):
    await state.update_data(file=message.document.file_id)
    async with state.proxy() as s:
        vacancy = Vacancy.get(Vacancy.id == s['vacancy_id'])
        file_path = settings.tasks_path_base + str(
            s['vacancy_id']) + '_' + message.document.file_name
        await bot.download_file_by_id(s['file'], file_path)
        vacancy.test_task = file_path
        vacancy.save()
    await state.finish()
    keyboard = InlineKeyboardMarkup()
    keyboard.add(InlineKeyboardButton(buttons.menu, callback_data='menu'))
    await message.answer(messages.saved_task, reply_markup=keyboard)
Пример #4
0
async def send_test_task_solution(query: callback_query, state: FSMContext):
    vacancy_id = int(query.data.split('_')[4])
    keyboard = InlineKeyboardMarkup()
    keyboard.add(
        InlineKeyboardButton(buttons.back,
                             callback_data='send_test_task_solutionback'))
    await SendTaskSolution.file.set()
    await state.update_data(vacancy_id=vacancy_id)
    candidate = Candidate.select().where(Candidate.user == User.get(User.chat_id == query.message.chat.id)) \
        .where(Candidate.vacancy == Vacancy.get(Vacancy.id == vacancy_id)).where(
        Candidate.status == 'Отправлено тестовое задание').get()
    await state.update_data(candidate_id=candidate.id)
    await query.message.answer(messages.send_me_solution,
                               reply_markup=keyboard)
Пример #5
0
async def show_vacancy_pure(chat_id, vacancy_id):
    vacancy = Vacancy.get(Vacancy.id == vacancy_id)
    keyboard = InlineKeyboardMarkup()
    await FindVacancy.id.set()

    keyboard.add(
        InlineKeyboardButton(buttons.additional_information,
                             callback_data='additional_information'))
    keyboard.add(
        InlineKeyboardButton(buttons.send_resume,
                             callback_data=f'send_resume_{vacancy_id}'))
    await bot.send_message(chat_id,
                           messages.vacancy_template.format(
                               vacancy.name, vacancy.specialization,
                               vacancy.description, vacancy.key_skills,
                               vacancy.income),
                           reply_markup=keyboard)
Пример #6
0
async def show_vacancy(query: callback_query, state: FSMContext):
    vacancy_id = int(query.data.split('_')[1])
    vacancy = Vacancy.get(Vacancy.id == vacancy_id)
    await state.update_data(id=vacancy_id)
    keyboard = InlineKeyboardMarkup()
    keyboard.add(
        InlineKeyboardButton(buttons.additional_information,
                             callback_data='additional_information'))
    keyboard.add(
        InlineKeyboardButton(buttons.back,
                             callback_data='back_to_find_vacancies'),
        InlineKeyboardButton(buttons.send_resume,
                             callback_data=f'send_resume_{vacancy_id}'))
    await query.message.answer(messages.vacancy_template.format(
        vacancy.name, vacancy.specialization, vacancy.description,
        vacancy.key_skills, vacancy.income),
                               reply_markup=keyboard)
Пример #7
0
async def name_find_vacancies(message: types.Message, state: FSMContext):
    await state.update_data(name=message.text)
    async with state.proxy() as find_vacancies_:
        name = find_vacancies_['name']
        rations = {}
        vacanncies = Vacancy.select()
        for i in vacanncies:
            rations[i.id] = fuzz.token_sort_ratio(name, i.name)
    await FindVacancy.next()
    rations = OrderedDict(
        sorted(rations.items(), key=itemgetter(1), reverse=True))
    keyboard = InlineKeyboardMarkup()
    for i in rations:
        vacancy = Vacancy.get(Vacancy.id == i)
        keyboard.add(
            InlineKeyboardButton(f'{vacancy.name} - {vacancy.income} руб.',
                                 callback_data=f'vacancy_{i}'))
    await message.answer(messages.what_we_found, reply_markup=keyboard)
Пример #8
0
async def vacancy_my(query: callback_query):
    vacancy_id = int(query.data.split('_')[2])
    keyboard = InlineKeyboardMarkup()
    vacancy = Vacancy.get(Vacancy.id == vacancy_id)
    keyboard.add(
        InlineKeyboardButton(buttons.delete_vacancy,
                             callback_data=f'delete_vacancy_{vacancy_id}'))
    if not vacancy.test_task:
        keyboard.add(
            InlineKeyboardButton(buttons.back, callback_data='vacancy_myback'),
            InlineKeyboardButton(buttons.add_tasks,
                                 callback_data=f'add_task_{vacancy_id}'))
    else:
        keyboard.add(
            InlineKeyboardButton(buttons.back, callback_data='vacancy_myback'))
    link = await get_start_link(str(vacancy_id), encode=True)
    await query.message.answer(messages.vacancy_template_with_deeplink.format(
        vacancy.name, vacancy.specialization, vacancy.description,
        vacancy.key_skills, vacancy.income, link),
                               reply_markup=keyboard)