Skip to content

Snow Leopards - Cristal & Francesca #39

Open
FrancescaFr wants to merge 20 commits intoAda-C18:mainfrom
FrancescaFr:main
Open

Snow Leopards - Cristal & Francesca #39
FrancescaFr wants to merge 20 commits intoAda-C18:mainfrom
FrancescaFr:main

Conversation

@FrancescaFr
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Keep it up for Task List API!

Be sure to follow any final refactors shown in Learn (e.g. splitting POST and GET ALL into separate routes), and refer back to the readings for anything else that you didn't have time to finish up in activity time while working on Task List.

Comment thread app/__init__.py
migrate = Migrate()
load_dotenv()

def create_app(test_config=None):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread app/models/planet.py
@@ -0,0 +1,23 @@
from app import db

class Planet(db.Model):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread app/routes.py

planet_bp = Blueprint("planets", __name__, url_prefix="/planets")

def validate_planet(id):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 Consider refactoring this to receive the class type as a parameter so that our validate helper could work for more than one type. This will be helpful in Task List when adding the Goal model.

Comment thread app/routes.py

return planet

@planet_bp.route("", methods=["GET", "POST"])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to refer to the second part of creating the get all endpoint where we avoid using multiple verbs in a single endpoint.

The multiple verb approach is possible, but generally we want to avoid that (single responsibility principle).

Comment thread app/routes.py
name_query = request.args.get("name")
flag_query = request.args.get("flag")

planet_query = Planet.query
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice job applying multiple filters.

Comment thread app/routes.py
def get_one_planet(id):
validate_planet(id)
planet = Planet.query.get(id)
return {"id": planet.id,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 Remember to use your .to_dict() here.

@@ -0,0 +1,28 @@
"""removed flag
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see that you went through a few migrations. Keep in mind that once you've gotten your "final" table layour squared away that it can be helpful to clear out all th old migrations, recreate the empty database, and get 1 nice, clean migration. Not something we'd want to do after having real data in a production database, but it's nice to start without migration clutter.

Comment thread tests/conftest.py
return app.test_client()

@pytest.fixture
def one_planet(app):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice single-planet fixture. And great job returning the value so that it can be used in a test directly!

Comment thread app/routes.py
flag=request_body["flag"])
db.session.add(new_planet)
db.session.commit()
return make_response(f"planet {new_planet.name} successfully created!", 201)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 Make sure to jsonify even plain string responses, otherwise flask will return an HTML response rather than JSON.

Comment thread app/routes.py
@@ -1,2 +1,53 @@
from flask import Blueprint
from flask import Blueprint, jsonify, abort, make_response, request
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 Make sure to review the readings for read, update, and delete (part 4) to make sure you have an idea for how to approach those.

Copy link
Copy Markdown
Author

@FrancescaFr FrancescaFr Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no! we somehow didn't push wave 4 of solar system...looks like we picked up on an older version to complete the rest of the waves... Should we update the pull request or leave it as is?

Copy link
Copy Markdown
Author

@FrancescaFr FrancescaFr Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are the additions in this commit - then I don't see how they disappeared: Commit: Wave 4 complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants