diff --git a/app.py b/app.py index 11e2013..e4ef6e9 100644 --- a/app.py +++ b/app.py @@ -16,6 +16,9 @@ def home() -> str: return render_template('home.html') +@app.route('/health') +def health_check(): + return '', 200 @app.route('/animals', methods=['GET']) def index() -> Response: @@ -28,8 +31,10 @@ def add_animal() -> tuple[Response, int]: data = AnimalCreate(**request.get_json()) new_animal = Animal( animal_type=data.animal_type, + animal_breed=data.animal_breed, name=data.name, - birth_date=data.birth_date + birth_date=data.birth_date, + photo_url=data.photo_url, ) db.session.add(new_animal) db.session.commit() @@ -40,7 +45,6 @@ def add_animal() -> tuple[Response, int]: } ), 201 - @app.route('/animal/', methods=['PUT']) def update_animal(pk: int) -> Union[Response, tuple[Response, int]]: data = AnimalCreate(**request.get_json()) @@ -49,8 +53,10 @@ def update_animal(pk: int) -> Union[Response, tuple[Response, int]]: return jsonify({"message": "Animal not found"}), 404 animal.animal_type = data.animal_type + animal.breed = data.animal_breed, animal.name = data.name animal.birth_date = data.birth_date + animal.photo_url = data.photo_url db.session.commit() return jsonify( { diff --git a/migrations/versions/e08fc0218f8b_.py b/migrations/versions/e08fc0218f8b_.py index 9a2228e..7a043cc 100644 --- a/migrations/versions/e08fc0218f8b_.py +++ b/migrations/versions/e08fc0218f8b_.py @@ -21,7 +21,9 @@ def upgrade(): op.create_table('animal', sa.Column('id', sa.Integer(), nullable=False), sa.Column('animal_type', sa.String(), nullable=False), + sa.Column('animal_breed', sa.String(), nullable=False), sa.Column('name', sa.String(), nullable=False), + sa.Column('photo_url', sa.String(), nullable=False), sa.Column('birth_date', sa.Date(), nullable=False), sa.PrimaryKeyConstraint('id') ) diff --git a/models/pydantic/models.py b/models/pydantic/models.py index 91e66db..4f41d06 100644 --- a/models/pydantic/models.py +++ b/models/pydantic/models.py @@ -4,7 +4,9 @@ class AnimalCreate(BaseModel): animal_type: str + animal_breed: str name: str + photo_url: str birth_date: date @@ -13,5 +15,7 @@ class AnimalResponse(BaseModel): id: int animal_type: str + animal_breed: str name: str + photo_url: str birth_date: date diff --git a/models/sqlalchemy/__init__.py b/models/sqlalchemy/__init__.py index 4fee0e2..3a7b0a7 100644 --- a/models/sqlalchemy/__init__.py +++ b/models/sqlalchemy/__init__.py @@ -4,5 +4,7 @@ class Animal(db.Model): id = db.Column(db.Integer, primary_key=True) animal_type = db.Column(db.String, nullable=False) + animal_breed = db.Column(db.String, nullable=False) name = db.Column(db.String, nullable=False) birth_date = db.Column(db.Date, nullable=False) + photo_url = db.Column(db.String, nullable=False) diff --git a/models/sqlalchemy/models.py b/models/sqlalchemy/models.py index dc6e14a..fadddc0 100644 --- a/models/sqlalchemy/models.py +++ b/models/sqlalchemy/models.py @@ -7,5 +7,7 @@ class Animal(db.Model): id = db.Column(db.Integer, primary_key=True) animal_type = db.Column(db.String, nullable=False) + animal_breed = db.Column(db.String, nullable=False) name = db.Column(db.String, nullable=False) birth_date = db.Column(db.Date, nullable=False) + photo_url = db.Column(db.String, nullable=False) diff --git a/templates/home.html b/templates/home.html index 80b942e..79eea06 100644 --- a/templates/home.html +++ b/templates/home.html @@ -25,6 +25,10 @@

Animals in the Shelter

+
+ + +
@@ -33,6 +37,10 @@

Animals in the Shelter

+
+ + +
@@ -44,8 +52,11 @@

List of animals:

Animal Type + Animal Breed Name Birth Date + Age + Photo Actions @@ -72,6 +83,10 @@ +
+ + +
@@ -80,6 +95,10 @@
+
+ + +