https://github.com/shakaran/django-cms-am
Django CMS Agile Monkeys Coding Hiring Test
https://github.com/shakaran/django-cms-am
Last synced: 25 days ago
JSON representation
Django CMS Agile Monkeys Coding Hiring Test
- Host: GitHub
- URL: https://github.com/shakaran/django-cms-am
- Owner: shakaran
- License: gpl-3.0
- Created: 2024-09-16T08:27:33.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-05-25T15:27:32.000Z (about 1 month ago)
- Last Synced: 2025-06-09T01:00:03.714Z (about 1 month ago)
- Language: Python
- Size: 454 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Django CMS Agile Monkeys Hiring Test
> This repo covers a [Agile Monkeys](https://www.theagilemonkeys.com) hiring recruiting test for a Django app
[](https://GitHub.com/shakaran/django-cms-am/graphs/commit-activity)
[](https://github.com/shakaran/django-cms-am/issues)
[](CODE_OF_CONDUCT.md)
[](https://actions-badge.atrox.dev/shakaran/django-cms-am/goto?ref=main)
[](https://www.gnu.org/licenses/agpl-3.0)
[](https://conventionalcommits.org)

## 🚀 Environment Setup
### 🐳 Needed tools
- Python 3
### 🛠️ Environment configuration
Enable virtualenv enviroment for app repo:
```bash
python3 -m venv env
source env/bin/activate
```## 👩💻 Project explanation
This repository contains a simple Django App with a Django REST API for customers.
### 🔥 Application execution
It is fully dockerized, with a .env.sample file where you can customize your credentials so run first time with:
```bash
docker-compose up --build
```Or by steps:
```bash
docker-compose build
docker-compose up
```After than run the migrations for first time with:
```bash
docker-compose exec web python manage.py migrate
```Then create a "root" superuser with:
```bash
docker-compose exec web python manage.py createsuperuser
```The static files could be collected with:
```bash
docker-compose exec web python manage.py collectstatic --noinput
```To enter to Django container web app:
```bash
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.
### ✅ Tests execution
You can run the test with:
```bash
docker-compose exec web python manage.py test
```Create an application oauth at [/admin/oauth2_provider/application/](http://0.0.0.0:8000/admin/oauth2_provider/application/)
## Test with curl:
### Authenticate a customer:
```bash
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"
``````bash
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"
```### List all customers (GET /customers/)
```bash
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X GET http://0.0.0.0:8000/customers/
```### Get details about a specific customer (GET /customers/{id}/)
```bash
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X GET http://0.0.0.0:8000/customers/1/
```### Create a new customer (POST /customers/)
```bash
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"
```### Update an existant customer (PUT /customers/{id}/)
```bash
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"
```### Delete a customer (DELETE /customers/{id}/)
```bash
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X DELETE http://0.0.0.0:8000/customers/1/
```### List all users (GET /users/)
This endpoint is only available for admin users.
```bash
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X GET http://0.0.0.0:8000/users/
```### Create a new user (POST /users/)
```bash
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X POST http://0.0.0.0:8000/users/ \
-d "username=newuser&[email protected]&password=newpassword"
```### Update an existant user (POST /users/) (PUT /users/{id}/)
```bash
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X PUT http://0.0.0.0:8000/users/1/ \
-d "username=updateduser&[email protected]"
```### Delete a user (DELETE /users/{id}/)
```bash
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-X DELETE http://0.0.0.0:8000/users/1/
```## Postman collection
There are a [provided Postman collection](postman-collection.json) for easy integration with all endpoints prefilled.