GithubHelp home page GithubHelp logo

phase-4-practice-car-dealership's Introduction

Flask Practice - Car Dealership

This application is being built to track cars sold by car dealerships.

Getting Started

Fork and clone this repo. Use pipenv install and pipenv shell to begin. Be sure to cd server.

There are no tests so be sure to use the flask shell and Postman to be certain everything's working correctly!

Models

You have three models:

Owner

  • first_name (string): Cannot be null
  • last_name (string): Cannot be null

Dealership

  • name (string): Cannot be null
  • address (string): Cannot be null

Car

  • make (string): Cannot be null
  • model (string): Cannot be null
  • date_sold (datetime): Cannot be null

Relationships

This is a many-to-many relationship.

  • An owner has many cars and a car belongs to an owner.

  • A dealership has many cars and a car belongs to a dealership.

  • A dealership has many owners and an owner has many dealerships through cars.

Owner --< Car >-- Dealership

The foreign keys aren't specified so you'll have to determine where they go.

Seeding

You can either use the seed.py to create your seeds or you can seed manually with flask shell.

Routes

Build out these routes:

Owner

GET /owners

Returns a list of all owners formatted like so:

[
    {
        "id": 1,
        "first_name": "Mohammad",
        "last_name": "Hossain"
    },
    {
        "id": 2,
        "first_name": "Alina",
        "last_name": "Pisarenko"
    }
]

GET /owners/:id

Returns an owner with the matching id. If there is no owner, returns a message that the owner could not be found along with a 404.

Format your owner object like so:

    {
        "id": 1,
        "first_name": "Mohammad",
        "last_name": "Hossain",
        "cars": [
            {
                "id": 1,
                "make": "Ford",
                "model": "Taurus",
                "date_sold": "2002-08-18 00:00:00"
            },
            {
                "id": 2,
                "make": "Chevrolet",
                "model": "Corvette",
                "date_sold": "2001-12-31 00:00:00"
            }
        ]
    }

DELETE /owners/:id

Deletes the owner and all associated cars from the database. Returns 204 if the owner was successfully deleted or 404 and an appropriate message if that owner could not be found.

Dealership

GET /dealerships

Returns a list of all dealerships.

[
    {
        "id": 1,
        "name": "Crazy Bob's Car Rodeo",
        "address": "123 Woodland Dr"
    },
    {
        "id": 2,
        "name": "King Auto's Castle",
        "address": "456 Roundtable Ln"
    }
]

GET /dealerships/:id

Returns a dealership with the matching id. If there is no dealership, returns a message that the dealership could not be found along with a 404.

{
    "id": 2,
    "name": "King Auto's Castle",
    "address": "456 Roundtable Ln"
}

Car

POST /cars

Creates a new car. The car must belong to a owner and a dealership. Return the new car details like so:

{
    "id": 3,
    "make": "Ford",
    "model": "Pinto",
    "owner": {
      "id": 2,
      "first_name": "Alina",
      "last_name": "Pisarenko"
    },
    "dealership": {
        "id": 1,
        "name": "Crazy Bob's Car Rodeo",
        "address": "123 Woodland Dr"
    }
}

DELETE /cars/:id

Deletes the car from the database. Returns 204 if the car was successfully deleted or 404 and an appropriate message if that car could not be found.

Please note the json that gets serialized may be a different order for any given response, don't focus on the order so much as making sure everything gets returned correctly...

phase-4-practice-car-dealership's People

Contributors

brewchetta 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.