Skip to content
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
248 changes: 248 additions & 0 deletions 100-dump.sql

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ Alexa Orrico - [Github](https://github.com/alexaorrico) / [Twitter](https://twit
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)
Ojewande Taofeek - [Github](https://github.com/ojewande-taofeek)
Nicolous Njorege - [Github](https://github.com/murnicole)

Second part of Airbnb: Joann Vuong
## License
Expand Down
Binary file added models/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/amenity.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/base_model.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/city.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/place.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/review.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/state.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/user.cpython-310.pyc
Binary file not shown.
Binary file added models/engine/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file not shown.
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
from uuid import uuid4
app = Flask(__name__)
# app.jinja_env.trim_blocks = True
# app.jinja_env.lstrip_blocks = True


@app.teardown_appcontext
def close_db(error):
""" Remove/Close 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)

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


if __name__ == "__main__":
""" Main Function """
app.run(host='0.0.0.0', port=5000)
47 changes: 47 additions & 0 deletions web_dynamic/1-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
from uuid import uuid4
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)

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


if __name__ == "__main__":
""" Main Function """
app.run(host='0.0.0.0', port=5000)
23 changes: 23 additions & 0 deletions web_dynamic/static/scripts/1-hbnb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Listen for changes on each input checkbox tag:
if the checkbox is checked, you must store the Amenity ID in a variable (dictionary or list)
if the checkbox is unchecked, you must remove the Amenity ID from the variable
update the h4 tag inside the div Amenities with the list of Amenities checked
*/

const amenDict = {};
$(function () {
$("input[type='checkbox']").on('change', function () {
const amenId = $(this).data('id');
const amenName = $(this).data('name');
if ($(this).is(':checked')) {
amenDict[amenId] = amenName;
} else {
delete amenDict[amenId];
}
const amenList = Object.values(amenDict).join(', ');
$('div.amenities > h4').text(amenList)
.css('white-space', 'nowrap')
.css('text-overflow', 'ellipsis');
});
});
78 changes: 78 additions & 0 deletions web_dynamic/templates/0-hbnb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../static/styles/4-common.css?{{ cache_id }}">
<link rel="stylesheet" type="text/css" href="../static/styles/3-header.css?{{ cache_id }}">
<link rel="stylesheet" type="text/css" href="../static/styles/3-footer.css?{{ cache_id }}">
<link rel="stylesheet" type="text/css" href="../static/styles/6-filters.css?{{ cache_id }}">
<link type="text/css" rel="stylesheet" href="../static/styles/8-places.css?{{ cache_id }}">
<link rel="icon" href="../static/images/icon.png" />
<title>HBnB</title>
</head>
<body>
<header>
<div class="logo"></div>
</header>
<div class="container">
<section class="filters">
<div class="locations">
<h3>States</h3>
<h4>&nbsp;</h4>
<div class="popover">
<ul>
{% for state in states %}
<li>
<h2>{{ state[0].name }}:</h2>
<ul>
{% for city in state[1] %}
<li>{{ city.name }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
</div>
<div class="amenities">
<h3>Amenities</h3>
<h4>&nbsp;</h4>
<div class="popover">
<ul>
{% for amenity in amenities %}
<li>{{ amenity.name }}</li>
{% endfor %}
</ul>
</div>
</div>
<button type="button">Search</button>
</section>
<div class="placesh1"><h1>Places</h1></div>
<section class="places">
<!-- <h1>Places</h1> -->
{% for place in places %}
<article>
<div class="title_box">
<h2>{{ place.name }}</h2>
<div class="price_by_night">${{ place.price_by_night }}</div>
</div>
<div class="information">
<div class="max_guest">{{ place.max_guest }} Guest{% if place.max_guest != 1 %}s{% endif %}</div>
<div class="number_rooms">{{ place.number_rooms }} Bedroom{% if place.number_rooms != 1 %}s{% endif %}</div>
<div class="number_bathrooms">{{ place.number_bathrooms }} Bathroom{% if place.number_bathrooms != 1 %}s{% endif %}</div>
</div>
<div class="user">
<b>Owner:</b> {{ place.user.first_name }} {{ place.user.last_name }}
</div>
<div class="description">
{{ place.description | safe }}
</div>
</article>
{% endfor %}
</section>
</div>
<footer>
<p>Holberton School</p>
</footer>
</body>
</html>
80 changes: 80 additions & 0 deletions web_dynamic/templates/1-hbnb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../static/styles/4-common.css?{{ cache_id }}">
<link rel="stylesheet" type="text/css" href="../static/styles/3-header.css?{{ cache_id }}">
<link rel="stylesheet" type="text/css" href="../static/styles/3-footer.css?{{ cache_id }}">
<link rel="stylesheet" type="text/css" href="../static/styles/6-filters.css?{{ cache_id }}">
<link type="text/css" rel="stylesheet" href="../static/styles/8-places.css?{{ cache_id }}">
<link rel="icon" href="../static/images/icon.png" />
<script src="https://code.jquery.com/jquery-3.2.1.min.js?{{ cache_id }}"></script>
<script type="text/javascript" src="../static/scripts/1-hbnb.js?{{ cache_id }}"></script>
<title>HBnB</title>
</head>
<body>
<header>
<div class="logo"></div>
</header>
<div class="container">
<section class="filters">
<div class="locations">
<h3>States</h3>
<h4>&nbsp;</h4>
<div class="popover">
<ul>
{% for state in states %}
<li>
<h2>{{ state[0].name }}:</h2>
<ul>
{% for city in state[1] %}
<li>{{ city.name }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
</div>
<div class="amenities">
<h3>Amenities</h3>
<h4>&nbsp;</h4>
<div class="popover">
<ul>
{% for amenity in amenities %}
<li><input type="checkbox" data-id="{{ amenity.id }}" data-name="{{ amenity.name }}">{{ amenity.name }}</li>
{% endfor %}
</ul>
</div>
</div>
<button type="button">Search</button>
</section>
<div class="placesh1"><h1>Places</h1></div>
<section class="places">
<!-- <h1>Places</h1> -->
{% for place in places %}
<article>
<div class="title_box">
<h2>{{ place.name }}</h2>
<div class="price_by_night">${{ place.price_by_night }}</div>
</div>
<div class="information">
<div class="max_guest">{{ place.max_guest }} Guest{% if place.max_guest != 1 %}s{% endif %}</div>
<div class="number_rooms">{{ place.number_rooms }} Bedroom{% if place.number_rooms != 1 %}s{% endif %}</div>
<div class="number_bathrooms">{{ place.number_bathrooms }} Bathroom{% if place.number_bathrooms != 1 %}s{% endif %}</div>
</div>
<div class="user">
<b>Owner:</b> {{ place.user.first_name }} {{ place.user.last_name }}
</div>
<div class="description">
{{ place.description | safe }}
</div>
</article>
{% endfor %}
</section>
</div>
<footer>
<p>Holberton School</p>
</footer>
</body>
</html>
Binary file not shown.
Binary file added web_flask/__pycache__/100-hbnb.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file added web_flask/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Empty file removed web_flask/templates/100-hbnb.html~
Empty file.