- Python3.6: Python is a programming language that lets you work quickly and integrate systems more effectively
- Django 2.2: Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
- Django REST framework: Django REST framework is a powerful and flexible toolkit for building Web APIs
- Django REST framework JWT: Django REST framework JWT This package provides JSON Web Token Authentication support for Django REST framework.
- Django REST Swagger: Django REST Swagger An API documentation generator for Swagger UI and Django REST Framework.
- Postgresql: PostgreSQL is a powerful, open source object-relational database system.
- Pipenv: Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world.
- Psycopg2: Psycopg is the most popular PostgreSQL adapter for the Python programming language.
Visit the links below for the API documentation
Vist this Link for the live application.
$ https://github.com/PatrickCmd/flight-booking-application.git
$ cd flight-booking-application
$ pip install pipenv
$ pipenv shell
$ pipenv install
Execute the commands in the terminal/console as stated below
Follow the Link on how to download and install postgres(>=10) on windows platform
Create Database
$ psql -U postgres
$postgres# CREATE DATABASE {dbname}; Where dbname is the database name
Setup Database URL environment variable
$ Rename env.example to .env and change the content as per your development settings
Install postgres
MAC Users
$ brew install postgres
Follow the link on how to setup brew if not yet installed
Ubuntu users
Follow the Link on how to setup and install postgres(>=10) on Ubuntu-linux platform
Create Database
$ psql -U postgres
$ postgres# CREATE DATABASE {dbname}; Where dbname is the database name
Setup Database URL environment variable
$ Rename env.example to .env and change the content as per your development settings
$ python manage.py migrate
$ python manage.py createsuperuser
$ python manage.py runserver_plus
Execute the url localhost:8000/ in your browser
Execute this command at the terminal
$ python manage.py test
{ "email": "[email protected]",
"password": "Example1234#",
"date_of_birth": "1900-11-19",
"first_name": "Example",
"middle_name": "",
"last_name": "Example Last",
"gender": "m",
"location": "Kyebando",
"phone": "256786893374"
}
{
"email": "[email protected]",
"password": "Example234#"
}
Create user profile: Methods['POST'] Authorization JWT-TOKEN token http://localhost:8000/fbs-api/profiles/
{
"using_country": "KENYA",
"country_of_citizenship": "KENYA",
"passport_number": "K510192823",
"issue_date": "2018-08-08",
"expiration_date": "2028-08-08",
"passport_photo": ""
}
Profile Details: Methods['GET', 'PUT/PATCH', 'DELETE'] Authorization JWT-TOKEN token http://localhost:8000/fbs-api/profiles/4/
Upload passport photo: Methods['POST'] Authorization JWT-TOKEN token http://localhost:8000/fbs-api/profiles/4/
Form data
{
'passport_photo': 'file.png or file.jpg'
}
Create Flight Admins[Superusers] only: Methods['POST'] Authorization JWT-TOKEN token http://localhost:8000/fbs-api/flights/
{
"name": "Entebbe to Denver",
"origin": "Entebbe",
"destination": "Denver",
"departure": "2019-08-02T08:00:00Z",
"arrival": "2019-08-03T07:00:00Z",
"aircraft": "Vintage",
"status": "ON_TIME",
"number": "KPQYWT72839",
"capacity": 120
}
Flight Details Admins[Superusers] only: Methods['PUT', 'DELETE'] Authorization JWT-TOKEN token http://localhost:8000/fbs-api/flights/<id>
{
"name": "Entebbe to Denver",
"origin": "Entebbe",
"destination": "Denver",
"departure": "2019-08-02T08:00:00Z",
"arrival": "2019-08-03T07:00:00Z",
"aircraft": "Vintage",
"status": "ON_TIME",
"number": "KPQYWT72839",
"capacity": 120
}
Make Reservation: Methods['POST'] Authorization JWT-TOKEN token http://localhost:8000/fbs-api/flights/<id>/reservation
{
'seat': 'A6'
}