- Python 3.11+
- pip
cd approval_system
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install djangorestframework django-cors-headerspython manage.py migratepython manage.py create_sample_dataThis creates:
- admin / admin123 (Admin role)
- manager / manager123 (Manager role)
- user / user123 (User role)
- Sample requests in various states
python manage.py runserver- Go to http://localhost:8000/admin/
- Login with
admin/admin123 - Browse Users, Requests, and Audit Logs
# Login as user
curl -c cookies.txt -X POST http://localhost:8000/admin/login/ \
-d "username=user&password=user123"
# View your requests
curl -b cookies.txt http://localhost:8000/api/v1/requests/
# Create a new request
curl -b cookies.txt -X POST http://localhost:8000/api/v1/requests/ \
-H "Content-Type: application/json" \
-d '{"title":"Test Request","description":"This is a test"}'- Login as user (user/user123)
- Create Request:
POST /api/v1/requests/ {"title": "Budget Request", "description": "Need $5000 for marketing"} - Submit for Approval:
POST /api/v1/requests/{id}/submit/
- Login as manager (manager/manager123)
- View assigned requests:
GET /api/v1/requests/
- Approve request:
POST /api/v1/requests/{id}/approve/
- Login as admin (admin/admin123)
- View all requests (all users)
- Check audit logs:
GET /api/v1/audit-logs/
Try invalid transitions to see error handling:
# Try to approve a draft request (should fail)
POST /api/v1/requests/{draft-id}/approve/Try unauthorized actions:
# Login as regular user
# Try to approve a request (should fail - permission denied)
POST /api/v1/requests/{id}/approve/Every action is logged:
- Who performed it
- What they did
- When it happened
- IP address
View in Django admin or check models:
- Users:
apps/users/models.py - Requests:
apps/requests/models.py - Audit Logs:
apps/audit_logs/models.py
python manage.py testAll tests should pass!
If you prefer Docker:
docker-compose up --build
docker-compose exec web python manage.py migrate
docker-compose exec web python manage.py create_sample_dataAccess at http://localhost:8000
- Read README.md for full documentation
- Check API_DOCUMENTATION.md for API details
- Review PROJECT_SUMMARY.md for architecture
rm db.sqlite3
python manage.py migrate
python manage.py create_sample_datapython manage.py runserver 8001Make sure you're in the virtual environment:
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows- Explore Admin Panel - See how data is organized
- Test API Endpoints - Use curl or Postman
- Read the Code - Start with
apps/users/models.py - Check Tests - See
apps/*/tests.pyfor examples - Modify & Extend - Add your own features!
- Use Django's browsable API at http://localhost:8000/api/v1/
- Check audit logs after every action
- Try different user roles to see permission differences
- Look at the code while using the system to understand flows