Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cedar - Jacy & Kit #15

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open

Cedar - Jacy & Kit #15

wants to merge 38 commits into from

Conversation

jacyyang04
Copy link

No description provided.

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

🎉 Nice work!

app/routes.py Outdated
planets_response = []

for planet in PLANETS:
planets_response.append(vars(planet))

Choose a reason for hiding this comment

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

nice use of vars!

Choose a reason for hiding this comment

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

I just learned that vars will cause problems when we have a class that connects to our database. We can achieve the same effect by writing a to_json(self) instance method on the Planet class.

app/routes.py Outdated
Comment on lines 3 to 22
from flask import Blueprint, jsonify


class Planet():
def __init__(self, id, name, description, xenomorphs=False):
self.id = id
self.name = name
self.description = description
self.xenomorphs = xenomorphs


PLANETS = [

Planet(426, "Nostromo's End", "Hostile weather. Toxic atmosphere. Evidence of civilization.", True),
Planet(224, "JollyPlanet", "Okay. Decent. Will live for long time.", True)

]

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

Choose a reason for hiding this comment

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

Minor note, consider moving extra spaces:

Suggested change
from flask import Blueprint, jsonify
class Planet():
def __init__(self, id, name, description, xenomorphs=False):
self.id = id
self.name = name
self.description = description
self.xenomorphs = xenomorphs
PLANETS = [
Planet(426, "Nostromo's End", "Hostile weather. Toxic atmosphere. Evidence of civilization.", True),
Planet(224, "JollyPlanet", "Okay. Decent. Will live for long time.", True)
]
planets_bp = Blueprint("planets_bp", __name__, url_prefix="/planets")
from flask import Blueprint, jsonify
class Planet():
def __init__(self, id, name, description, xenomorphs=False):
self.id = id
self.name = name
self.description = description
self.xenomorphs = xenomorphs
PLANETS = [
Planet(426, "Nostromo's End", "Hostile weather. Toxic atmosphere. Evidence of civilization.", True),
Planet(224, "JollyPlanet", "Okay. Decent. Will live for long time.", True)
]
planets_bp = Blueprint("planets_bp", __name__, url_prefix="/planets")

Copy link

@kaidamasaki kaidamasaki left a comment

Choose a reason for hiding this comment

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

Great job!

It's too bad your planets seem to have a case of xenomorphs though!

"id": self.id,
"name": self.name,
"description": self.description,
"xenomorphs": self.xenomorphs

Choose a reason for hiding this comment

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

Oh no!

Comment on lines +48 to +53
##---partial functionality; would like to discuss---##
if name_query:
planets = Planet.query.filter_by(name=name_query)
elif xenomorphs_query:
planets = Planet.query.filter_by(xenomorphs=xenomorphs_query)
##---END---##

Choose a reason for hiding this comment

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

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.

4 participants