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

Esekyi #272

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv/
__pycache__/
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This file lists all individuals having contributed content to the repository.


Chinaza Ukwe <[email protected]>
Emmanuel Sekyi <[email protected]>
Jennifer Huang <[email protected]>
Alexa Orrico <[email protected]>
Joann Vuong <[email protected]>

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ No known bugs at this time.
Alexa Orrico - [Github](https://github.com/alexaorrico) / [Twitter](https://twitter.com/alexa_orrico)
Jennifer Huang - [Github](https://github.com/jhuang10123) / [Twitter](https://twitter.com/earthtojhuang)
Jhoan Zamora - [Github](https://github.com/jzamora5) / [Twitter](https://twitter.com/JhoanZamora10)
David Ovalle - [Github](https://github.com/Nukemenonai) / [Twitter](https://twitter.com/disartDave)
David Ovalle - [Github](https://github.com/Nukemenonai) / [Twitter](https://twitter.com/disartDave)
Emmanuel Sekyi - [Github](https://github.com/Esekyi)


Second part of Airbnb: Joann Vuong
## License
Expand Down
3 changes: 1 addition & 2 deletions api/v1/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
app = Flask(__name__)
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
app.register_blueprint(app_views)
cors = CORS(app, resources={r"/*": {"origins": "0.0.0.0"}})

cors = CORS(app, resources={r"/api/v1/*": {"origins": "*"}})

@app.teardown_appcontext
def close_db(error):
Expand Down
216 changes: 216 additions & 0 deletions file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"BaseModel.dd52e210-0a0a-4f48-aba9-129c09d5b083": {
"id": "dd52e210-0a0a-4f48-aba9-129c09d5b083",
"created_at": "2024-08-06T04:50:24.300285",
"updated_at": "2024-08-06T04:50:24.300285",
"__class__": "BaseModel"
},
"State.965c91e6-1c6b-4001-88de-fde415e4d2ca": {
"name": "Arizona",
"created_at": "2024-08-06T10:12:09.276009",
"updated_at": "2024-08-06T10:12:09.276047",
"id": "965c91e6-1c6b-4001-88de-fde415e4d2ca",
"__class__": "State"
},
"State.92038c0a-7701-4499-8d9c-e3cf04511298": {
"name": "Ohio",
"created_at": "2024-08-06T10:16:13.211148",
"updated_at": "2024-08-06T10:16:13.211231",
"id": "92038c0a-7701-4499-8d9c-e3cf04511298",
"__class__": "State"
},
"State.d8e94fa2-2710-40e0-9d3c-40ed5b00c681": {
"name": "Texas",
"created_at": "2024-08-06T10:16:52.657918",
"updated_at": "2024-08-06T10:16:52.658001",
"id": "d8e94fa2-2710-40e0-9d3c-40ed5b00c681",
"__class__": "State"
},
"State.6e2d673d-ba64-434f-919b-8c5d70193e1b": {
"name": "Florida",
"created_at": "2024-08-06T10:17:02.766481",
"updated_at": "2024-08-06T10:17:02.766538",
"id": "6e2d673d-ba64-434f-919b-8c5d70193e1b",
"__class__": "State"
},
"State.c76968c7-4d3a-4042-93c1-3c9a3d4c5d9b": {
"name": "California",
"created_at": "2024-08-06T10:17:10.514532",
"updated_at": "2024-08-06T10:17:10.514570",
"id": "c76968c7-4d3a-4042-93c1-3c9a3d4c5d9b",
"__class__": "State"
},
"State.e45594a4-2824-4075-9a86-70ce3653a144": {
"name": "tr",
"created_at": "2024-08-06T10:53:45.495555",
"updated_at": "2024-08-06T10:53:45.495647",
"id": "e45594a4-2824-4075-9a86-70ce3653a144",
"__class__": "State"
},
"City.147fbef5-061d-4e79-896b-e2e901bf99b3": {
"name": "Miami",
"created_at": "2024-08-07T04:32:32.007342",
"updated_at": "2024-08-07T04:32:32.007399",
"id": "147fbef5-061d-4e79-896b-e2e901bf99b3",
"state_id": "6e2d673d-ba64-434f-919b-8c5d70193e1b",
"__class__": "City"
},
"City.d807b069-c052-4f8d-b2c7-a7bd63008892": {
"name": "Orlando",
"created_at": "2024-08-07T04:33:08.636635",
"updated_at": "2024-08-07T04:33:08.636683",
"id": "d807b069-c052-4f8d-b2c7-a7bd63008892",
"state_id": "6e2d673d-ba64-434f-919b-8c5d70193e1b",
"__class__": "City"
},
"City.3b6f9ce1-ca57-4dc5-8cdc-d734d1c818b8": {
"name": "Tallahassee",
"created_at": "2024-08-07T04:38:45.238888",
"updated_at": "2024-08-07T04:38:45.238924",
"id": "3b6f9ce1-ca57-4dc5-8cdc-d734d1c818b8",
"state_id": "6e2d673d-ba64-434f-919b-8c5d70193e1b",
"__class__": "City"
},
"City.5200d721-e515-4247-afa9-75e892066b87": {
"name": "Tucson",
"created_at": "2024-08-07T04:40:20.831317",
"updated_at": "2024-08-07T04:40:20.831363",
"id": "5200d721-e515-4247-afa9-75e892066b87",
"state_id": "965c91e6-1c6b-4001-88de-fde415e4d2ca",
"__class__": "City"
},
"City.0a41acee-1caa-4661-9d45-93ba6e816b24": {
"name": "Yuma",
"created_at": "2024-08-07T04:41:00.856309",
"updated_at": "2024-08-07T04:41:00.856345",
"id": "0a41acee-1caa-4661-9d45-93ba6e816b24",
"state_id": "965c91e6-1c6b-4001-88de-fde415e4d2ca",
"__class__": "City"
},
"Amenity.63b9e893-f4ad-4a52-af20-666b555fa52e": {
"name": "Cable Tv",
"created_at": "2024-08-11T05:36:27.934054",
"updated_at": "2024-08-11T05:36:27.934446",
"id": "63b9e893-f4ad-4a52-af20-666b555fa52e",
"__class__": "Amenity"
},
"Amenity.608a70a2-0dd1-46a2-9d6d-2bf0b0878fe7": {
"name": "Air Conditioning",
"created_at": "2024-08-11T05:44:08.346441",
"updated_at": "2024-08-11T05:44:08.346588",
"id": "608a70a2-0dd1-46a2-9d6d-2bf0b0878fe7",
"__class__": "Amenity"
},
"Amenity.b9fa984a-2db2-4642-a944-c978d1680a1f": {
"name": "Breackfast",
"created_at": "2024-08-11T05:44:31.028926",
"updated_at": "2024-08-11T05:44:31.028973",
"id": "b9fa984a-2db2-4642-a944-c978d1680a1f",
"__class__": "Amenity"
},
"Amenity.aead74ea-84c2-487d-8a0f-5f4e233d0332": {
"name": "Dogs",
"created_at": "2024-08-11T05:52:54.136181",
"updated_at": "2024-08-11T05:52:54.136390",
"id": "aead74ea-84c2-487d-8a0f-5f4e233d0332",
"__class__": "Amenity"
},
"Amenity.76f89e99-3a4c-444a-875d-4b331f89c8d4": {
"name": "Doorman",
"created_at": "2024-08-11T05:52:59.947820",
"updated_at": "2024-08-11T05:52:59.947864",
"id": "76f89e99-3a4c-444a-875d-4b331f89c8d4",
"__class__": "Amenity"
},
"Amenity.f519229f-7571-4569-9130-5739efd2edac": {
"name": "Cat(s)",
"created_at": "2024-08-11T05:53:17.010840",
"updated_at": "2024-08-11T05:53:17.010882",
"id": "f519229f-7571-4569-9130-5739efd2edac",
"__class__": "Amenity"
},
"User.1e4c7ec4-2711-44a9-96d4-8f04bb4e8b80": {
"email": "[email protected]",
"password": "51e2831f7c824b48adb2fb194949003d",
"first_name": "Sekyi",
"last_name": "Skert",
"created_at": "2024-08-11T06:10:52.994434",
"updated_at": "2024-08-11T06:10:52.994912",
"id": "1e4c7ec4-2711-44a9-96d4-8f04bb4e8b80",
"__class__": "User"
},
"User.08e66463-fd13-4c09-97b4-e7cb03cee6f9": {
"email": "[email protected]",
"password": "bb37c85cff2917a43fa8ab7253b40ab6",
"first_name": "Sekyi",
"last_name": "Skert",
"created_at": "2024-08-11T06:11:27.925884",
"updated_at": "2024-08-11T06:11:27.925954",
"id": "08e66463-fd13-4c09-97b4-e7cb03cee6f9",
"__class__": "User"
},
"Place.9b9a3ac4-61fa-4620-8533-028a76c310d6": {
"city_id": "3b6f9ce1-ca57-4dc5-8cdc-d734d1c818b8",
"user_id": "08e66463-fd13-4c09-97b4-e7cb03cee6f9",
"name": "Beautiful Studio Rooms",
"amenity_ids": "608a70a2-0dd1-46a2-9d6d-2bf0b0878fe7",
"description": "If you use a multi-element selector, like the class selector we used in the previous example, and we know that we're looking for elements of a specific type, it's good practice to specify the element type before the selector. Not only is it more precise, it's also faster for jQuery to process, resulting in more responsive sites. Here is a re-written version of the previous example, where we use this method:",
"max_guest": 2,
"numeber_rooms": 4,
"numeber_bathrooms": 8,
"created_at": "2024-08-11T06:28:11.585076",
"updated_at": "2024-08-11T06:28:11.585344",
"id": "9b9a3ac4-61fa-4620-8533-028a76c310d6",
"__class__": "Place"
},
"City.a703dc2b-4eb8-4998-badd-82e6f1e8b857": {
"name": "Galveston",
"created_at": "2024-08-11T06:39:55.484038",
"updated_at": "2024-08-11T06:39:55.484190",
"id": "a703dc2b-4eb8-4998-badd-82e6f1e8b857",
"state_id": "d8e94fa2-2710-40e0-9d3c-40ed5b00c681",
"__class__": "City"
},
"Place.4cabf5b6-552d-4bd1-8943-c0e85aae5981": {
"user_id": "08e66463-fd13-4c09-97b4-e7cb03cee6f9",
"name": "Baywatch Dolphin Tour",
"amenity_ids": [
"608a70a2-0dd1-46a2-9d6d-2bf0b0878fe7",
"63b9e893-f4ad-4a52-af20-666b555fa52e",
"76f89e99-3a4c-444a-875d-4b331f89c8d4"
],
"description": "This Galveston Baywatch Dolphin Tour is a great way to see dolphins on the water in just a few hours. Meet your group and captain at Pier 21 and join the boat you\u2019re assigned for this experience. Then, take off on the water to enjoy some time searching for dolphins in their natural habitat. Catch sight of dolphins in their natural habitat during this Galveston tour Perfect for nature lovers who are short on time No need to rush on board\u2014all seats offer great viewing opportunities A captain knows the best areas on the water to spot dolphins",
"max_guest": 6,
"numeber_rooms": 8,
"numeber_bathrooms": 3,
"price_by_night": 329,
"latitude": -94.792802857672,
"longitude": "29.309400464654054",
"city_id": "a703dc2b-4eb8-4998-badd-82e6f1e8b857",
"created_at": "2024-08-11T06:49:19.954826",
"updated_at": "2024-08-11T06:49:19.955034",
"id": "4cabf5b6-552d-4bd1-8943-c0e85aae5981",
"__class__": "Place"
},
"Place.03f48f7e-7c47-4b20-98c5-729e093be6f7": {
"user_id": "08e66463-fd13-4c09-97b4-e7cb03cee6f9",
"name": "Baywatch Dolphin Tour",
"amenity_ids": [
"608a70a2-0dd1-46a2-9d6d-2bf0b0878fe7",
"63b9e893-f4ad-4a52-af20-666b555fa52e",
"76f89e99-3a4c-444a-875d-4b331f89c8d4"
],
"description": "This Galveston Baywatch Dolphin Tour is a great way to see dolphins on the water in just a few hours. Meet your group and captain at Pier 21 and join the boat you\u2019re assigned for this experience. Then, take off on the water to enjoy some time searching for dolphins in their natural habitat. Catch sight of dolphins in their natural habitat during this Galveston tour Perfect for nature lovers who are short on time No need to rush on board\u2014all seats offer great viewing opportunities A captain knows the best areas on the water to spot dolphins",
"max_guest": 6,
"numeber_rooms": 8,
"numeber_bathrooms": 3,
"price_by_night": 329,
"latitude": -94.792802857672,
"longitude": 29.309400464654054,
"city_id": "a703dc2b-4eb8-4998-badd-82e6f1e8b857",
"created_at": "2024-08-11T06:51:43.027322",
"updated_at": "2024-08-11T06:51:43.027374",
"id": "03f48f7e-7c47-4b20-98c5-729e093be6f7",
"__class__": "Place"
}
}
47 changes: 47 additions & 0 deletions web_dynamic/0-hbnb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python3
""" Starts a Flash Web Application """
from models import storage
from models.state import State
from models.city import City
from models.amenity import Amenity
from models.place import Place
from os import environ
from flask import Flask, render_template
import uuid
app = Flask(__name__)
# app.jinja_env.trim_blocks = True
# app.jinja_env.lstrip_blocks = True


@app.teardown_appcontext
def close_db(error):
""" Remove the current SQLAlchemy Session """
storage.close()


@app.route('/0-hbnb', strict_slashes=False)
def hbnb():
""" HBNB is alive! """
states = storage.all(State).values()
states = sorted(states, key=lambda k: k.name)
st_ct = []

for state in states:
st_ct.append([state, sorted(state.cities, key=lambda k: k.name)])

amenities = storage.all(Amenity).values()
amenities = sorted(amenities, key=lambda k: k.name)

places = storage.all(Place).values()
places = sorted(places, key=lambda k: k.name)

return render_template('0-hbnb.html',
cache_id=uuid.uuid4(),
states=st_ct,
amenities=amenities,
places=places)


if __name__ == "__main__":
""" Main Function """
app.run(host='0.0.0.0', port=5000)
53 changes: 53 additions & 0 deletions web_dynamic/1-hbnb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/python3
""" Starts a Flash Web Application """
from models import storage
from models.state import State
from models.city import City
from models.amenity import Amenity
from models.place import Place
from models.user import User
from os import environ
from flask import Flask, render_template
import uuid
app = Flask(__name__)
# app.jinja_env.trim_blocks = True
# app.jinja_env.lstrip_blocks = True


@app.teardown_appcontext
def close_db(error):
""" Remove the current SQLAlchemy Session """
storage.close()


@app.route('/1-hbnb', strict_slashes=False)
def hbnb():
""" HBNB is alive! """
states = storage.all(State).values()
states = sorted(states, key=lambda k: k.name)
st_ct = []

for state in states:
st_ct.append([state, sorted(state.cities, key=lambda k: k.name)])

amenities = storage.all(Amenity).values()
amenities = sorted(amenities, key=lambda k: k.name)

places = storage.all(Place).values()
places = sorted(places, key=lambda k: k.name)

places_with_users = []
for place in places:
user = storage.get(User, place.user_id)
places_with_users.append((place, user))

return render_template('1-hbnb.html',
cache_id=uuid.uuid4(),
states=st_ct,
amenities=amenities,
places=places_with_users)


if __name__ == "__main__":
""" Main Function """
app.run(host='0.0.0.0', port=5000)
12 changes: 10 additions & 2 deletions web_flask/100-hbnb.py → web_dynamic/100-hbnb.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
from models.city import City
from models.amenity import Amenity
from models.place import Place
from models.user import User
from os import environ
from flask import Flask, render_template
import uuid
app = Flask(__name__)
# app.jinja_env.trim_blocks = True
# app.jinja_env.lstrip_blocks = True
Expand All @@ -18,7 +20,7 @@ def close_db(error):
storage.close()


@app.route('/hbnb', strict_slashes=False)
@app.route('/100-hbnb', strict_slashes=False)
def hbnb():
""" HBNB is alive! """
states = storage.all(State).values()
Expand All @@ -34,10 +36,16 @@ def hbnb():
places = storage.all(Place).values()
places = sorted(places, key=lambda k: k.name)

places_with_users = []
for place in places:
user = storage.get(User, place.user_id)
places_with_users.append((place, user))

return render_template('100-hbnb.html',
cache_id=uuid.uuid4(),
states=st_ct,
amenities=amenities,
places=places)
places=places_with_users)


if __name__ == "__main__":
Expand Down
Loading