Giter VIP home page Giter VIP logo

airbnb_clone_v2's Introduction

hbnb

Airbnb Clone Console

Contents


Description

In the next few months, we at Holberton School will be creating the AirBnB clone project, and how it says is a clone of the AirBnB application. We will face and develop this project in parts like:

  • The console
  • Web static
  • MySQL storage
  • Web framework - templating
  • RESTful API
  • Web dynamic

Technology

In this repository we face the third part: MySQL storage. In this part we have the transition between FileStorage to DBStorage to control the data in a database with columns, tables and relationships to consult, update or create information in our data base, we are based on this diagram:

This is the final part of our project:


Installation

https://github.com/dario-castano/AirBnB_clone_v2.git

Requirements

This console was built and tested in Ubuntu 14.04LTS, interpreted/compiled using Python3

All the test should be executed by using this command: python3 -m unittest discover tests

Also you can test file by file using this command: python3 -m unittest tests/test_models/test_base_model.py


Directories and Files


Directories


Directory Description
models This package contains the modules and classes to create an specific object
engine This package contains the module to manage the file storage
tests This package contains all the test for models and classes
scripts This directory contains the script to generate the AUTHORS file

Files Description
console.py The console file
AUTHORS This file contains all the authors of this project
Models directory

File Description
amenity.py The amenity subclass
base_model.py The base model superclass
city.py The city subclass
place.py The place subclass
review.py The review subclass
state.py The state subclass
user.py The user subclass

Engine directory


File Description
file_storage.py The file storage class
db_storage.py DBStorage

Tests directory


File Description
test_amenity.py Unittest module for amenity
test_base_model.py Unittest module for base model
test_city.py Unittest module for city
test_place.py Unittest module for place
test_review.py Unittest module for review
test_state.py Unittest module for state
test_user.py Unittest module for user
test_engine/test_file_storage.py Unittest module for file storage

Commands


Basic commands to use the console


Command Usage Example Functionality
help help help Display the list of the commands that can be executed
create create <class> create Place Creates a new instance of a class
show show <class> <id> show Place 123-123-123 Shows a specific instance
destroy destroy <class> <id> destroy Place 123-123-123 deletes a specific instance
all all or all <class> all Place Shows all instances or shows an entire class
update update <class> <id> <attribute> <value> update User 123-123-123 email '[email protected]' Updates an specific attribute of an instance
quit quit quit Quits the console
EOF Ctr+D EOF Quits the console with keyboard interruption

Usage

To run : ./console.py or non-interactive mode run echo "command to run" | ./console.py


Example Commands

Interactive Mode

Display the command help and do two empty lines


$ ./console.py
(hbnb) help

Documented commands (type help <topic>):
========================================
EOF  all  count  create  destroy  help  quit  show  update
(hbnb)
(hbnb)
(hbnb)
(hbnb) quit
$

Using the commands


$ ./console.py
(hbnb) create BaseModel
5dccfbf9-03a6-45f7-8a75-80094392bf97
(hbnb) show BaseModel 5dccfbf9-03a6-45f7-8a75-80094392bf97
[BaseModel] (5dccfbf9-03a6-45f7-8a75-80094392bf97) {'id': '5dccfbf9-03a6-45f7-8a75-80094392bf97', 'updated_at': datetime.datetime(2018, 6, 13, 23, 10, 13, 549740), 'created_at': datetime.datetime(2018, 6, 13, 23, 10, 13, 549699)}
(hbnb) all
[[BaseModel] (5dccfbf9-03a6-45f7-8a75-80094392bf97) {'id': '5dccfbf9-03a6-45f7-8a75-80094392bf97', 'updated_at': datetime.datetime(2018, 6, 13, 23, 10, 13, 549740), 'created_at': datetime.datetime(2018, 6, 13, 23, 10, 13, 549699)}]
(hbnb) BaseModel.count
1
(hbnb) update BaseModel 5dccfbf9-03a6-45f7-8a75-80094392bf97 number 89
(hbnb) show BaseModel 5dccfbf9-03a6-45f7-8a75-80094392bf97
[BaseModel] (5dccfbf9-03a6-45f7-8a75-80094392bf97) {'number': '89', 'updated_at': datetime.datetime(2018, 6, 13, 23, 11, 51, 470426), 'created_at': datetime.datetime(2018, 6, 13, 23, 10, 13, 549699), 'id': '5dccfbf9-03a6-45f7-8a75-80094392bf97'}
(hbnb) create User
71e19890-6440-4ca9-9976-59ba61571f09
(hbnb) all
[[User] (71e19890-6440-4ca9-9976-59ba61571f09) {'id': '71e19890-6440-4ca9-9976-59ba61571f09', 'updated_at': datetime.datetime(2018, 6, 13, 23, 12, 39, 71568), 'created_at': datetime.datetime(2018, 6, 13, 23, 12, 39, 71532)}, [BaseModel] (5dccfbf9-03a6-45f7-8a75-80094392bf97) {'number': '89', 'updated_at': datetime.datetime(2018, 6, 13, 23, 11, 51, 470426), 'created_at': datetime.datetime(2018, 6, 13, 23, 10, 13, 549699), 'id': '5dccfbf9-03a6-45f7-8a75-80094392bf97'}]
(hbnb) destroy User 71e19890-6440-4ca9-9976-59ba61571f09
(hbnb) all
[[BaseModel] (5dccfbf9-03a6-45f7-8a75-80094392bf97) {'number': '89', 'updated_at': datetime.datetime(2018, 6, 13, 23, 11, 51, 470426), 'created_at': datetime.datetime(2018, 6, 13, 23, 10, 13, 549699), 'id': '5dccfbf9-03a6-45f7-8a75-80094392bf97'}]
(hbnb) destroy BaseModel 5dccfbf9-03a6-45f7-8a75-80094392bf97
(hbnb) all
[]
(hbnb) create Place city_id="0001" user_id="0001" name="My_little_house" number_rooms=4 number_bathrooms=2 max_guest=10 price_by_night=300 latitude=37.773972 longitude=-122.431297
76b65327-9e94-4632-b688-aaa22ab8a124
(hbnb) quit
$

Non-Interactive Mode

Display the command help


$ echo "help" | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF  all  count  create  destroy  help  quit  show  update

(hbnb) $
$

Using the commands


$ echo "create BaseModel" | ./console.py
(hbnb) f09bfbad-532d-4bbe-a2c1-815b1958f01e
(hbnb) $
$ echo "all" | ./console.py
(hbnb) [[BaseModel] (f09bfbad-532d-4bbe-a2c1-815b1958f01e) {'id': 'f09bfbad-532d-4bbe-a2c1-815b1958f01e', 'updated_at': datetime.datetime(2018, 6, 13, 23, 16, 30, 420332), 'created_at': datetime.datetime(2018, 6, 13, 23, 16, 30, 420300)}]
(hbnb) $
$ echo "destroy BaseModel f09bfbad-532d-4bbe-a2c1-815b1958f01e" | ./console.py
(hbnb) (hbnb) $
$ echo "all" | ./console.py
(hbnb) []
(hbnb) $
$

Build with

Authors

Initial authors:

Miranda Evans [email protected]

Kevin Yook [email protected]

We are:

Dario Castaño - Twitter - :octocat:

Daniela Chamorro - Twitter - :octocat:

airbnb_clone_v2's People

Contributors

yook00627 avatar dalexach avatar dario-castano avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.