Beispiel #1
0
def pet_list_null_owner():
    """
    Get a list of pets from null owner.
    """
    results = Pet.select().where(Pet.owner.is_null()).order_by(
        Pet.id.desc()).execute()
    response = generate_response(
        {'data': [model_to_dict(result) for result in results]}, 200)
    return response
Beispiel #2
0
def pet_list(person_id):
    """
    Get a list of pets from an existing owner.
    """
    try:
        owner = Person.get_or_none(Person.id == person_id)
        if owner is None:
            raise NotFoundException('Owner not found')

        results = Pet.select().where(Pet.owner == person_id).order_by(
            Pet.id.desc()).execute()
        response = generate_response(
            {'data': [model_to_dict(result) for result in results]}, 200)
    except Exception as e:
        app.logger.error(e)
        response = generate_error_response(e)

    return response