Пример #1
0
def change_job_application_state(id: int):  # noqa: E501
    """Changes a state of a job application by its id.

     # noqa: E501

    :param id:
    :type id: int

    :rtype: None
    """
    search_id_query = {"_id": id}
    try:
        new_state = connexion.request.json.get('state')
        update_object = {"state": new_state}
        if JobApplicationState.is_readonly(new_state):
            update_object['dateClosed'] = datetime.now()

        JobApplicationService.update_job_application(search_id_query,
                                                     update_object)
        return None, 200
    except RestException as re:
        print(re)
        return get_error_dto(re.error_type, re.status_code, re.info)
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_applications.unknown")
Пример #2
0
def get_job_offer(id: int, includeApplications=False):  # noqa: E501
    """Gets a job offer by its id.

     # noqa: E501

    :param id:
    :type id: int
    :param includeApplications:
    :type includeApplications: bool

    :rtype: JobOffer
    """
    search_id_query = {"_id": id}
    try:
        job_offer = JobOfferService.find_job_offer(search_id_query)

        if includeApplications:
            job_applications_query = {"jobOfferId": id}
            job_offer[
                'applications'] = JobApplicationService.find_job_applications(
                    job_applications_query)
        return job_offer, 200
    except RestException as re:
        print(re)
        return get_error_dto(re.error_type, re.status_code, re.info)
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_offers.unknown")
Пример #3
0
def create_job_application():  # noqa: E501
    """Creates a job application.

     # noqa: E501

    :rtype: GetJobApplicationDto
    """
    try:
        dto = CreateJobApplicationDto.from_dict(connexion.request.json)
        JobApplicationService.create_job_application(dto)
    except RestException as re:
        print(re)
        return get_error_dto(re.error_type, re.status_code, re.info)
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_applications.unknown")
Пример #4
0
def create_job_offer():  # noqa: E501
    """Creates a Job offer.

     # noqa: E501

    :rtype: JobOffer
    """
    dto = CreateJobOfferDto.from_dict(connexion.request.json)
    try:
        json = JobOfferService.create_job_offer(dto)
        return json, 200
    except RestException as re:
        print(re)
        return get_error_dto(re.error_type, re.status_code, re.info)
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_offers.unknown")
Пример #5
0
def get_job_application(id: int):  # noqa: E501
    """Gets a job application by its id.

     # noqa: E501

    :param id:
    :type id: int

    :rtype: GetJobApplicationDto
    """
    search_id_query = {"_id": id}
    try:
        job_application = JobApplicationService.find_job_application(
            search_id_query)
        return job_application, 200
    except RestException as re:
        print(re)
        return get_error_dto(re.error_type, re.status_code, re.info)
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_applications.unknown")
Пример #6
0
def update_job_offer(id: int):  # noqa: E501
    """Updates a job offer by its id.

     # noqa: E501

    :param id:
    :type id: int

    :rtype: None
    """
    search_query = {"_id": id}
    try:
        new_state = connexion.request.json.get('state')
        JobOfferService.update_job_offer(search_query, new_state)
        return None, 200
    except RestException as re:
        print(re)
        return get_error_dto(re.error_type, re.status_code, re.info)
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_offers.unknown")
Пример #7
0
def get_job_offers():  # noqa: E501
    """Gets all Job offers.

     # noqa: E501

    :rtype: List[JobOffer]
    """
    try:
        job_offers = JobOfferService.find_job_offers()
        return job_offers, 200
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_offers.unknown")
Пример #8
0
def update_job_application(id: int):  # noqa: E501
    """Updates an application by its id.

     # noqa: E501

    :param id:
    :type id: int

    :rtype: None
    """
    search_id_query = {"_id": id}
    new_note = connexion.request.json.get('note')
    update_object = {"note": new_note}
    try:
        JobApplicationService.update_job_application(search_id_query,
                                                     update_object)
        return None, 200
    except RestException as re:
        print(re)
        return get_error_dto(re.error_type, re.status_code, re.info)
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_applications.unknown")
Пример #9
0
def get_job_applications():  # noqa: E501
    """Gets all Job applications.

     # noqa: E501


    :rtype: List[JobApplication]
    """
    try:
        job_applications = JobApplicationService.find_job_applications()
        return job_applications, 200
    except Exception as e:
        print(e)
        return get_error_dto("errors.job_applications.unknown")