Create a web client form and an API endpoint for travel permit inquiries using Django.
API must take the following fields as input:
- Date of travel
- Date of return (optional)
- Country of origin
- Country of destination
- Age of traveller
- Date of travel is between the next 2 and 5 following working days from the date of request. Otherwise, the travel permit must be denied.
- If Date of return is present, and date of return is within 2 months of the Date of travel, then the travel can be approved. In any other case the travel permit must be denied.
- Country of origin and Country of destination must be valid country names.
- Travel is only allowed from countries where the number of Covid cases in the Country of origin is lower than in the Country of destination.
- Travel is only allowed for travellers older than 21 and younger than 65. However, if a traveler is older than 15 years old, he/she can travel with the supervision of an adult. (You must show this prompt in your output when appropriate)
- Tests for the above scenarios
To run the solution ensure to meet the following:
- Ubuntu 18+
- Python3
- Postgres10+
To run solution follow the steps below
# install required libraries
pip install -r requirements.txt
# Configure database
1. Access postgres service
2. Create database
3. Assignment priviledges to user
# Create .env
1. cp .env.example .env
2. Change variables according to your prefence
Run develop server
# Migrate migrations
./manage.py migrate
# Run server
./manage.py runserver
# Create Super User
./manage.py createsuperuser
# Run Development Server
./manage.py runserver
./manage.py test travel
To access solution, open your preferred browser ensure the development server is running.
http://localhost:8000
http://localhost:8000/travel/permit/
https://travelpermitpbp.herokuapp.com
https://travelpermitpbp.herokuapp.com/admin
username: admin
password: admin123456
https://docs.google.com/document/d/1MZylx2UKexWxbwZNZmLpXzUeY2JaLWZDQ4Q8FphUvdk/edit?usp=sharing