forked from AdaGold/solar-system-api
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Sarah and Brooke - Pine - Part 1 #16
Open
sarahstandish
wants to merge
25
commits into
Ada-C16:main
Choose a base branch
from
sarahstandish:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
31dbb71
create notes doc
sarahstandish aa5a6c2
Merge branch 'Ada-C16:main' into main
sarahstandish 814cbbb
Class Planet defined + Class method defined
goblinbrooke 154ed68
add dictionary method
sarahstandish 01764a7
add psuedocode
sarahstandish b621559
list of planet instances
sarahstandish 98ed786
Add planets blueprint and handle_planets endpoint
sarahstandish 18c4af5
Part 1 Final :)
goblinbrooke a3557bf
Set Up + Initialize SQLA/Migrate
goblinbrooke 44d2a28
Created new Planet Class
goblinbrooke d3187ca
GET and POST
goblinbrooke a1b8368
"Fixed Bugs"
goblinbrooke 4e2dd6d
various bug fixes
sarahstandish f598d14
"GET 1 Planet"
goblinbrooke 731a994
not sure what these changes are
sarahstandish 41fac9b
resolved merge conflict, hopefully
sarahstandish b0b6235
resolving changes
sarahstandish d4a4e7d
resolve merge conflicts
sarahstandish 4c217a9
DESTROYED PLANET
goblinbrooke 6f9fc10
resolve merge conflict
sarahstandish 6befe84
resolve merge conflicts AGAIN
sarahstandish 532261e
add PUT route
sarahstandish ebfb222
fix error in delete endpoint
sarahstandish 97e5006
"Test Config + First Test"
goblinbrooke d4c6775
All Tests Passed!! Final
goblinbrooke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from .planets import Planet | ||
|
||
planets = [ | ||
Planet("Mercury", "Closest to the sun, hot.", False), | ||
Planet("Venus", "Spins the opposite direction of other planets.", False), | ||
Planet("Earth", "You are here."), | ||
Planet("Mars", "Red planet."), | ||
Planet("Jupiter", "Gas Giant."), | ||
Planet("Saturn", "Has rings."), | ||
Planet("Uranus", "Controversy over pronunciation."), | ||
Planet("Neptune", "Smallest gas giant, with faint rings."), | ||
Planet("Pluto", "Brooke still believes!") | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Planet: | ||
number_of_planets = 0 | ||
def __init__(self, name, description, has_moons=True): | ||
self.name = name | ||
self.description = description | ||
self.has_moons = has_moons | ||
self.id = Planet.number_of_planets | ||
Planet.increase_number_of_planets() | ||
|
||
@classmethod | ||
def increase_number_of_planets(Planet): | ||
Planet.number_of_planets += 1 | ||
|
||
def create_planet_dictionary(self): | ||
return { | ||
"id": self.id, | ||
"name": self.name, | ||
"description": self.description, | ||
"has moons": self.has_moons | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great helper function! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
from flask import Blueprint | ||
from flask import Blueprint, jsonify | ||
from .list_of_planets import planets | ||
|
||
planets_bp = Blueprint("planets", __name__, url_prefix="/planets") | ||
|
||
@planets_bp.route("", methods=["GET"]) | ||
def handle_planets(): | ||
|
||
list_of_planets = [] | ||
for planet in planets: | ||
list_of_planets.append(planet.create_planet_dictionary()), 200 | ||
|
||
return jsonify(list_of_planets) | ||
|
||
@planets_bp.route("/<planet_id>", methods=["GET"]) | ||
def handle_planet(planet_id): | ||
for planet in planets: | ||
if int(planet_id) == planet.id: | ||
return jsonify(planet.create_planet_dictionary()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Notes | ||
Follow the directions in Learn - Building an API part 1 activity | ||
This will be very similar to the 'books' API |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat idea!