Giter Site home page Giter Site logo

py-tickets-orders's Introduction

Tickets and Orders API

Read the guideline before starting.

  • Use the following command to load prepared data from fixture to test and debug your code:

    python manage.py loaddata cinema_service_db_data.json

  • After loading data from fixture you can use following superuser (or create another one by yourself):

    • Login: admin.user
    • Password: 1qazcde3

`In this task you will add the functionality of working with orders.

  1. Create serializers and views to support the following endpoints:
  • GET api/cinema/orders/ - should return a list of the all orders that filtered by the authenticated user. Add detail information about movie session and implement pagination.

Example:

GET /api/cinema/orders/?page=2
HTTP 200 OK
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 3,
    "next": "http://127.0.0.1:8000/api/cinema/orders/?page=3",
    "previous": "http://127.0.0.1:8000/api/cinema/orders/",
    "results": [
        {
            "id": 2,
            "tickets": [
                {
                    "id": 2,
                    "row": 2,
                    "seat": 3,
                    "movie_session": {
                        "id": 1,
                        "show_time": "2022-12-12T12:32:00Z",
                        "movie_title": "Movie",
                        "cinema_hall_name": "Green",
                        "cinema_hall_capacity": 2829
                    }
                }
            ],
            "created_at": "2022-05-16T13:45:30.911367Z"
        }
    ]
}
  • POST api/cinema/orders/ - should create a new order for the authenticated user. It should support the following request structure:
{
    "tickets": [
        {
            "row": 2,
            "seat": 1,
            "movie_session": 1
        },
        {
            "row": 2,
            "seat": 2,
            "movie_session": 1
        }
    ]
}
  1. Provide filtering for movies by genres, actors and title. Use ?actors=, ?genres= and ?title= parameters. Filtering by title with the string parameter should return all movies whose title contains string.

  2. Implement filtering for movie sessions by date and movie. The date should be provided in year-month-day format, the movie by its id. Example:

GET /api/cinema/movie_sessions/?date=2022-12-12&movie=1
HTTP 200 OK
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

[
    {
        "id": 1,
        "show_time": "2022-12-12T12:32:00Z",
        "movie_title": "Movie",
        "cinema_hall_name": "Green",
        "cinema_hall_capacity": 2829
    }
]
  1. Return taken places for movie session details endpoint
GET /api/cinema/movie_sessions/1/
HTTP 200 OK
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1,
    "show_time": "2022-12-12T12:32:00Z",
    "movie": {
        "id": 1,
        "title": "Movie",
        "description": "description",
        "duration": 123,
        "genres": [
            "drama"
        ],
        "actors": [
            "F F"
        ]
    },
    "cinema_hall": {
        "id": 1,
        "name": "Green",
        "rows": 123,
        "seats_in_row": 23,
        "capacity": 2829
    },
    "taken_places": [
        {
            "row": 2,
            "seat": 1
        },
        {
            "row": 2,
            "seat": 3
        },
        {
            "row": 2,
            "seat": 10
        }
    ]
}

  1. Add tickets_available field to movie sessions list endpoint, which says about how many tickets are still available for each movie_session

Optional tasks:

  • Provide validation for creating tickets on serializer level

Note: Check your code using this checklist before pushing your solution.

py-tickets-orders's People

Contributors

ivanramyk avatar nattalli avatar abnormaltype avatar dmytrosvirsa avatar masterpieceelbow avatar tpolina avatar y-havryliv avatar danylott avatar maxitoska 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.