Giter Site home page Giter Site logo

kamalinux / airbnb_clone Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 144 KB

This is the first phase of a four phase project, to create a basic clone of the AirBnB web app. destroy to the existing classes and subclasses.

Python 40.35% HTML 44.67% CSS 14.99%

airbnb_clone's Introduction

Hi there 👋

airbnb_clone's People

Contributors

kamalinux avatar

Watchers

 avatar

Forkers

tndtopito

airbnb_clone's Issues

Task 8. First User

Write a class User that inherits from BaseModel:

  • models/user.py

  • Public class attributes:

  • email: string - empty string
    password: string - empty string
    first_name: string - empty string
    last_name: string - empty string

  • Update FileStorage to manage correctly serialization and deserialization of User.

  • Update your command interpreter (console.py) to allow show, create, destroy, update and all used with User.

Task 9. More classes!

Write all those classes that inherit from BaseModel:

  • State (models/state.py):

  • Public class attributes:
    name: string - empty string

  • City (models/city.py):

  • Public class attributes:
    state_id: string - empty string: it will be the State.id
    name: string - empty string

  • Amenity (models/amenity.py):

  • Public class attributes:
    name: string - empty string

  • Place (models/place.py):

  • Public class attributes:
    city_id: string - empty string: it will be the City.id
    user_id: string - empty string: it will be the User.id
    name: string - empty string
    description: string - empty string
    number_rooms: integer - 0
    number_bathrooms: integer - 0
    max_guest: integer - 0
    price_by_night: integer - 0
    latitude: float - 0.0
    longitude: float - 0.0
    amenity_ids: list of string - empty list: it will be the list of Amenity.id later

  • Review (models/review.py):

  • Public class attributes:
    place_id: string - empty string: it will be the Place.id
    user_id: string - empty string: it will be the User.id
    text: string - empty string

Task 3. BaseModel class

Write a class BaseModel that defines all common attributes/methods for other classes:

Public instance attributes:

  • id: string - assign with an uuid when an instance is created
  • created_at: datetime - assign with the current datetime when an instance is created
  • updated_at: datetime - assign with the current datetime when an instance is created and it will be updated every time you change your object

Special method:

  • str: should print: [] (<self.id>) <self.dict>

Public instance methods:

  • save(self): updates the public instance attribute updated_at with the current datetime
  • to_dict(self): returns a dictionary containing all keys/values of dict of the instance

Task 2. Unittests

All your files, classes, functions must be tested with unit tests.

  • Unit test for task 3. BaseModel
  • Unit test for task 4. Create BaseModel from dictionary
  • Unit test for task 5. Store first object
  • Unit test for task 8. First User
  • Unit test for task 9. More classes!
  • Unit test for task 10. Console 1.0

Task 6. Console 0.0.1

Write a program called console.py that contains the entry point of the command interpreter:

  • cmd
  • class HBNBCommand(cmd.Cmd):

Your command interpreter should implement:

  • quit and EOF to exit the program
  • help
  • a custom prompt: (hbnb)
  • an empty line + ENTER shouldn’t execute anything

Task 10. Console 1.0

  • Update FileStorage to manage correctly serialization and deserialization of all our new classes: Place, State, City, Amenity and Review

  • Update your command interpreter (console.py) to allow those actions: show, create, destroy, update and all with all classes created previously.

No unittests needed for the console

Task 5. Store first object

Write a class FileStorage that serializes instances to a JSON file and deserializes JSON file to instances:

Private class attributes:

  • __file_path: string - path to the JSON file (ex: file.json)
  • __objects: dictionary - empty but will store all objects by .id (ex: to store a BaseModel object with id=12121212, the key will be BaseModel.12121212)

Public instance methods:

  • all(self): returns the dictionary __objects
  • new(self, obj): sets in __objects the obj with key .id
  • save(self): serializes __objects to the JSON file (path: __file_path)
  • reload(self): deserializes the JSON file to __objects (only if the JSON file (__file_path) exists ; otherwise, do nothing. If the file doesn’t exist, no exception should be raised)

Update models/init.py: to create a unique FileStorage instance for your application

  • import file_storage.py
  • create the variable storage, an instance of FileStorage
  • call reload() method on this variable

Update models/base_model.py: to link your BaseModel to FileStorage by using the variable storage

  • import the variable storage
  • in the method save(self): call save(self) method of storage
  • init(self, *args, **kwargs): if it’s a new instance (not from a dictionary representation), add a call to the method new(self) on storage

Task 0. Authors and README

Write a README.md:

  • description of the project
  • description of the command interpreter: (how to start it, how to use it and examples)

Write an AUTHORS:

  • Listing all individuals having contributed content to the repository with Docker's format.

GitHub repository:

  • Git flow, You should use branches and pull requests on GitHub.

Task 7. Console 0.1

Update your command interpreter (console.py) to have these commands:

  • create: Creates a new instance of BaseModel, saves it (to the JSON file) and prints the id. Ex: $ create BaseModel)

  • If the class name is missing, print ** class name missing ** (ex: $ create)
    If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ create MyModel)

  • show: Prints the string representation of an instance based on the class name and id. Ex: $ show BaseModel 1234-1234-1234.

  • If the class name is missing, print ** class name missing ** (ex: $ show)
    If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ show MyModel)
    If the id is missing, print ** instance id missing ** (ex: $ show BaseModel)
    If the instance of the class name doesn’t exist for the id, print ** no instance found ** (ex: $ show BaseModel 121212)

  • destroy: Deletes an instance based on the class name and id (save the change into the JSON file). Ex: $ destroy BaseModel 1234-1234-1234.

  • If the class name is missing, print ** class name missing ** (ex: $ destroy)
    If the class name doesn’t exist, print ** class doesn't exist ** (ex:$ destroy MyModel)
    If the id is missing, print ** instance id missing ** (ex: $ destroy BaseModel)
    If the instance of the class name doesn’t exist for the id, print ** no instance found ** (ex: $ destroy BaseModel 121212)

  • all: Prints all string representation of all instances based or not on the class name. Ex: $ all BaseModel or $ all.

  • The printed result must be a list of strings (like the example below)
    If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ all MyModel)

  • update: Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file). Ex: $ update BaseModel 1234-1234-1234 email "[email protected]".

  • Usage: update <class name> <id> <attribute name> "<attribute value>"
    Only one attribute can be updated at the time
    You can assume the attribute name is valid (exists for this model)
    The attribute value must be casted to the attribute type
    If the class name is missing, print ** class name missing ** (ex: $ update)
    If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ update MyModel)
    If the id is missing, print ** instance id missing ** (ex: $ update BaseModel)
    If the instance of the class name doesn’t exist for the id, print ** no instance found ** (ex: $ update BaseModel 121212)
    If the attribute name is missing, print ** attribute name missing ** (ex: $ update BaseModel existing-id)
    If the value for the attribute name doesn’t exist, print ** value missing ** (ex: $ update BaseModel existing-id first_name)
    All other arguments should not be used (Ex: $ update BaseModel 1234-1234-1234 email "[email protected]" first_name "Betty" = $ update BaseModel 1234-1234-1234 email "[email protected]")
    id, created_at and updated_at cant’ be updated. You can assume they won’t be passed in the update command
    Only “simple” arguments can be updated: string, integer and float. You can assume nobody will try to update list of ids or datetime

  • Let’s add some rules:

  • You can assume arguments are always in the right order
    Each arguments are separated by a space
    A string argument with a space must be between double quote
    The error management starts from the first argument to the last one

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.