Skip to content

feat: Complete ice cream automate implementation #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[bandit]
exclude_dirs = ["tests", "venv", ".venv"]
skips = ["B101", "B601"]
15 changes: 15 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]
max-line-length = 88
extend-ignore = E203, W503, E501
exclude =
.git,
__pycache__,
venv,
.venv,
migrations,
.tox,
build,
dist
per-file-ignores =
__init__.py:F401
settings.py:E501
79 changes: 79 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Virtual environments
venv/
env/
ENV/
env.bak/
venv.bak/

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
Thumbs.db

# Testing
.coverage
.pytest_cache/
htmlcov/
.tox/
.cache
nosetests.xml
coverage.xml

# Static files
/static/
/staticfiles/
/media/

# Linting
.mypy_cache/
.flake8_cache/

# Pre-commit
.pre-commit-config.yaml.bak

# Project specific
*.sqlite3
*.db

# VS Code workspace
*.code-workspace
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8

- repo: https://github.com/pycqa/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ['-r', '.']
exclude: tests/
21 changes: 21 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[MASTER]
load-plugins = pylint_django
django-settings-module = nalo_automate.settings

[FORMAT]
max-line-length = 88

[MESSAGES CONTROL]
disable =
missing-docstring,
too-few-public-methods,
import-error,
no-member,
unused-argument

[DESIGN]
max-args = 7
max-locals = 15
max-returns = 6
max-branches = 12
max-statements = 50
171 changes: 171 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Makefile for Nalo Ice Cream Automate
# Professional Django development workflow

.PHONY: help install run clean test lint format check init mock serve logs shell migrate docs build commit cz-commit bump changelog

# Default target
help: ## Show this help message
@echo "Nalo Ice Cream Automate - Available commands:"
@echo ""
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""

# Development environment
install: ## Install dependencies and setup environment
python -m venv venv || true
. venv/bin/activate && pip install --upgrade pip
. venv/bin/activate && pip install -r requirements.txt
@echo "✅ Dependencies installed"

init: ## Initialize project for first time (migrations + mock data)
. venv/bin/activate && python manage.py makemigrations ice_cream
. venv/bin/activate && python manage.py migrate
. venv/bin/activate && python manage.py init_flavors
@echo "✅ Project initialized with database and flavors"

mock: ## Generate mock data for testing
. venv/bin/activate && python manage.py generate_sample_orders --count 10
@echo "✅ Mock data generated"

# Server management
run: ## Run development server
. venv/bin/activate && python manage.py runserver

serve: ## Alternative to run (same as run)
$(MAKE) run

logs: ## Show server logs (if running in background)
tail -f nohup.out

# Database operations
migrate: ## Apply database migrations
. venv/bin/activate && python manage.py makemigrations
. venv/bin/activate && python manage.py migrate
@echo "✅ Migrations applied"

shell: ## Open Django shell
. venv/bin/activate && python manage.py shell

# Cleaning
clean: ## Clean cache and temporary files
find . -name "*.pyc" -delete
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name "*.pyo" -delete
find . -name ".coverage" -delete
find . -name "htmlcov" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name ".pytest_cache" -type d -exec rm -rf {} + 2>/dev/null || true
@echo "✅ Cache and temporary files cleaned"

# Code quality
format: ## Format code with black and isort
. venv/bin/activate && black --line-length 88 .
. venv/bin/activate && isort --profile black .
@echo "✅ Code formatted with black and isort"

lint: ## Run linting with flake8 and pylint
. venv/bin/activate && flake8 --max-line-length=88 --extend-ignore=E203,W503 .
. venv/bin/activate && pylint --load-plugins=pylint_django --django-settings-module=nalo_automate.settings ice_cream/ nalo_automate/ || true
@echo "✅ Linting completed"

check: ## Run all code quality checks
$(MAKE) format
$(MAKE) lint
. venv/bin/activate && python manage.py check
@echo "✅ All code quality checks completed"

fix: ## Auto-fix common issues
. venv/bin/activate && autopep8 --in-place --aggressive --aggressive --recursive .
. venv/bin/activate && black --line-length 88 .
. venv/bin/activate && isort --profile black .
@echo "✅ Auto-fixes applied"

# Testing
test: ## Run all tests
. venv/bin/activate && python manage.py test --verbosity=2

test-coverage: ## Run tests with coverage report
. venv/bin/activate && coverage run --source='.' manage.py test
. venv/bin/activate && coverage report
. venv/bin/activate && coverage html
@echo "✅ Tests completed with coverage report in htmlcov/"

test-fast: ## Run tests without coverage (faster)
. venv/bin/activate && python manage.py test --parallel --keepdb

# Commitizen
commit: cz-commit
cz-commit:
@echo "Starting interactive commit..."
cz commit

bump:
@echo "Bumping version..."
cz bump

bump-dry:
@echo "Dry run version bump..."
cz bump --dry-run

changelog:
@echo "Generating changelog..."
cz changelog

pre-commit-install:
@echo "Installing pre-commit hooks..."
pip install pre-commit
pre-commit install
pre-commit install --hook-type commit-msg

validate-commit:
cz check --rev-range HEAD

# Documentation
docs: ## Generate API documentation
@echo "📚 API Documentation available at:"
@echo " - Swagger UI: http://127.0.0.1:8000/api/docs/"
@echo " - ReDoc: http://127.0.0.1:8000/api/redoc/"
@echo " - Schema: http://127.0.0.1:8000/api/schema/"


# Development workflow
dev: ## Complete development setup
$(MAKE) clean
$(MAKE) install
$(MAKE) init
$(MAKE) mock
$(MAKE) check
$(MAKE) test
@echo "🚀 Development environment ready!"
@echo "Run 'make run' to start the server"

# Quick commands
quick-test: ## Quick test run (most common)
$(MAKE) clean
$(MAKE) format
$(MAKE) test-fast

restart: ## Clean restart
$(MAKE) clean
$(MAKE) run

kill-server: ## Kill any running server on port 8000
lsof -ti:8000 | xargs kill -9 2>/dev/null || true
@echo "✅ Server killed"

# Status
status: ## Show project status
@echo "📊 Nalo Ice Cream Automate Status:"
@echo ""
@echo "🐍 Python environment:"
@. venv/bin/activate && python --version
@echo ""
@echo "📦 Django status:"
@. venv/bin/activate && python manage.py check --deploy 2>/dev/null && echo "✅ Django OK" || echo "❌ Django issues"
@echo ""
@echo "🗄️ Database:"
@. venv/bin/activate && python manage.py showmigrations --plan | tail -5
@echo ""
@echo "🍦 Flavors in DB:"
@. venv/bin/activate && python manage.py shell -c "from ice_cream.models import Flavor; print(f'{Flavor.objects.count()} flavors')" 2>/dev/null || echo "Not initialized"
@echo ""
@echo "📋 Available commands: make help"
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,41 @@ Un utilisateur a le choix du nombre de boule et des parfums.
- [ ] Publie-le sur GitHub en tant que `pull-request`
- [ ] Envoie-nous le lien et dis-nous approximativement combien de temps tu as passé sur ce travail.

# Nalo Ice Cream Automate

Système de gestion d'automate de glaces avec API REST et interface web.

## Installation et lancement

```bash
# Setup complet (première fois)
make dev

# Ou étape par étape
make install # Installation des dépendances
make init # Base de données + parfums
make run # Lancement du serveur
```

Accès : http://127.0.0.1:8000

## Fonctionnalités

* API : `/api/orders/`, `/api/flavors/`, `/api/refill-pot/`
* Interface : Commande, récupération, administration
* Documentation : http://127.0.0.1:8000/api/docs/

## Tests et qualité

```bash
make test
make test-coverage
make check
make clean
```

## Structure

5 parfums disponibles (Chocolat Orange, Cerise, Pistache, Vanille, Framboise)
40 boules par pot, 2€ par boule
Gestion automatique des stocks + alertes
Binary file removed cherry.jpg
Binary file not shown.
Binary file removed chocolate-orange.jpg
Binary file not shown.
Empty file added ice_cream/__init__.py
Empty file.
Loading