This repo covers a Agile Monkeys hiring recruiting test for a Django app
- Python 3
Enable virtualenv enviroment for app repo:
python3 -m venv env
source env/bin/activate
This repository contains a simple Django App with a Django REST API for customers.
It is fully dockerized, with a .env.sample file where you can customize your credentials so run first time with:
docker-compose up --build
Or by steps:
docker-compose build
docker-compose up
After than run the migrations for first time with:
docker-compose exec web python manage.py migrate
Then create a "root" superuser with:
docker-compose exec web python manage.py createsuperuser
The static files could be collected with:
docker-compose exec web python manage.py collectstatic --noinput
To enter to Django container web app:
docker-compose exec -it web bash
Access the application at http://0.0.0.0/:8000 in your web browser.
Use the provided Django admin interface by visiting http://0.0.0.0:8000/admin and logging in with the superuser credentials.
You can run the test with:
docker-compose exec web python manage.py test
Create an application oauth at /admin/oauth2_provider/application/
curl -X POST http://0.0.0.0:8000/auth/token/ \
-d "grant_type=password&username=test&password=test&client_id=your_client_id&client_secret=your_client_secret"
curl -X POST http://0.0.0.0:8000/auth/token/ \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password&username=testuser&password=testpassword&client_id=your-client-id&client_secret=your-client-secret"
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X GET http://0.0.0.0:8000/customers/
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X GET http://0.0.0.0:8000/customers/1/
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X POST http://0.0.0.0:8000/customers/ \
-F "name=John" \
-F "surname=Doe" \
-F "customer_id=12345" \
-F "photo=@/path/to/photo.jpg"
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X PUT http://0.0.0.0:8000/customers/1/ \
-F "name=Jane" \
-F "surname=Doe" \
-F "customer_id=67890" \
-F "photo=@/path/to/new_photo.jpg"
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X DELETE http://0.0.0.0:8000/customers/1/
This endpoint is only available for admin users.
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X GET http://0.0.0.0:8000/users/
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X POST http://0.0.0.0:8000/users/ \
-d "username=newuser&[email protected]&password=newpassword"
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X PUT http://0.0.0.0:8000/users/1/ \
-d "username=updateduser&[email protected]"
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X DELETE http://0.0.0.0:8000/users/1/
There are a provided Postman collection for easy integration with all endpoints prefilled.