Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
5b57790
Initial commit
Jeremuller Jan 12, 2026
c5469b3
Initial commit
Jeremuller Jan 12, 2026
2ca2a70
First linting updates/ compatibility updates.
Jeremuller Jan 12, 2026
a7de62b
Created lettings app
Jeremuller Jan 23, 2026
6505090
Created profiles app
Jeremuller Jan 23, 2026
990d353
Updated INSTALLED_APPS.
Jeremuller Jan 23, 2026
665aa1c
Remove IDE files from version control.
Jeremuller Jan 23, 2026
f92bdb4
Moved models in proper app, and deleted the "old" version.
Jeremuller Jan 26, 2026
a53bca6
Corrected import, and transfered admin contents in app-related files.…
Jeremuller Jan 26, 2026
a1a6e0b
Restored those file to their ancient state from github.
Jeremuller Feb 1, 2026
89e2706
Worked out the migration of the tables by pointing to the old ones vi…
Jeremuller Feb 1, 2026
7cd6db1
Added the migration files
Jeremuller Feb 2, 2026
4d58c78
Run migration for profile table, sync django and db, and renamed tabl…
Jeremuller Feb 5, 2026
b0b07a8
Applied previous migration plan for lettings app, everything seems to…
Jeremuller Feb 5, 2026
11840b9
Changed urls calls to fit with name spaces
Jeremuller Feb 20, 2026
6da4ff7
Updated urls post migration
Jeremuller Feb 20, 2026
3eb9810
Created views, and transfered functions properly
Jeremuller Feb 20, 2026
d1af5e2
Deleted unused files
Jeremuller Feb 20, 2026
6711742
last migration and update for architecture refactoring
Jeremuller Feb 20, 2026
6a41ba1
Deleted unused imports
Jeremuller Feb 20, 2026
100a9f2
Updated requirements.txt
Jeremuller Feb 22, 2026
97c33be
Added documentation for lettings files.
Jeremuller Feb 25, 2026
51b86df
Added documentation on profiles app code
Jeremuller Feb 25, 2026
6330725
Added documentation on og_lettings_site files, and manage.py
Jeremuller Feb 25, 2026
d49e29e
Added documentation on og_lettings_site files, and manage.py
Jeremuller Feb 25, 2026
f65ad1d
Created a conftest file for tests in tellings app
Jeremuller Feb 25, 2026
3243943
Created a few unittests for lettings.models
Jeremuller Feb 25, 2026
7ba9288
Created a few unittests for lettings.urls
Jeremuller Feb 26, 2026
7d2857d
Created a few unittests for lettings.views, all lettings files are un…
Jeremuller Feb 26, 2026
287fd38
Deleted unused imports
Jeremuller Mar 3, 2026
dc61b41
Added unit tests for oc_letting_site.urls
Jeremuller Mar 7, 2026
285375c
Added unit tests for oc_letting_site.views
Jeremuller Mar 7, 2026
7b81a3f
Added a conftest.py for profiles app
Jeremuller Mar 7, 2026
07c5a26
Updated conftest, and created unit tests for profiles.models.
Jeremuller Mar 7, 2026
f93c4e6
Updated conftest, and created unit tests for profiles.urls
Jeremuller Mar 7, 2026
8fabd7e
Updated conftest, and created unit tests for profiles.views
Jeremuller Mar 7, 2026
7cf6d2f
"Added integration tests for lettings app with happy, edge and TDD 40…
Jeremuller Mar 9, 2026
8e050d5
Added integration tests for oc_letting_site app with happy, sad and e…
Jeremuller Mar 9, 2026
4b88e4b
Added integration tests for oc_letting_site app with happy, sad, edge…
Jeremuller Mar 9, 2026
3f2c226
Downloaded pytest-coverage, and created a conf test for it, coverage …
Jeremuller Mar 9, 2026
6161a17
Corrected pluralisation error on admin panel by adding verbose_name_p…
Jeremuller Apr 4, 2026
f19a9b0
Added proper error 404 and 500 handling, with dedicated templates and…
Jeremuller Apr 4, 2026
6ab28e2
Updated tests to include an error 500 test, and updated a few docstri…
Jeremuller Apr 4, 2026
a05ced0
Installed sentry-sdk for django, added keys in .env and updated requi…
Jeremuller Apr 11, 2026
cbbd341
Modified sentry settings
Jeremuller Apr 11, 2026
32bfe4a
Added different levels of loggers
Jeremuller Apr 11, 2026
a36e6eb
Added different levels of loggers for profiles.views
Jeremuller Apr 11, 2026
9da3ccc
Added different levels of loggers for lettings.views
Jeremuller Apr 13, 2026
42ba56a
Update coverage
Jeremuller Apr 15, 2026
548951b
Working on docker and CI pipeline, currently runnin container on loca…
Jeremuller Apr 27, 2026
1b81b20
Updated architecture with gunicorn to get ready for production
Jeremuller May 5, 2026
3b5dc6c
First test for compilation part of the pipeline
Jeremuller May 11, 2026
28bd519
Second test for compilation part of the pipeline
Jeremuller May 11, 2026
30e0647
Second test for compilation part of the pipeline
Jeremuller May 11, 2026
c364d50
Third test for compilation part of the pipeline with secret written o…
Jeremuller May 11, 2026
7a99935
Added coverage check for validating CI
Jeremuller May 12, 2026
ade31a1
Added coverage check for validating CI
Jeremuller May 12, 2026
4d0aaa7
Test incorrect linting for CI
Jeremuller May 12, 2026
b972d66
Test incorrect linting for CI
Jeremuller May 12, 2026
f1783af
Roll back to proper linting
Jeremuller May 12, 2026
5e97b6e
Renamed ci.yml
Jeremuller May 12, 2026
a349aca
Renamed ci.yml
Jeremuller May 12, 2026
e871343
Renamed ci.yml
Jeremuller May 12, 2026
5a3c2fe
Added postgresql driver for django on requirements.txt
Jeremuller May 14, 2026
151be2e
Test pipeline
Jeremuller May 15, 2026
ad7d38e
Updated postgre stack, migration succeeded, database not filled yet.
Jeremuller May 22, 2026
35982b0
Database is now populated, site is running, and datas seams to be cle…
Jeremuller May 25, 2026
4c25ca3
Test, using sqlite db for CI tests
Jeremuller May 29, 2026
7885545
Test, using sqlite db for CI tests
Jeremuller May 29, 2026
30ada86
Test, using sqlite db for CI tests
Jeremuller May 29, 2026
a51fa10
Test, using sqlite db for CI tests
Jeremuller Jun 1, 2026
54f8b87
Test, using sqlite db for CI tests
Jeremuller Jun 1, 2026
9163096
Test, using sqlite db for CI tests
Jeremuller Jun 1, 2026
3f6e177
Test, using sqlite db for CI tests
Jeremuller Jun 1, 2026
d422e93
Removed debugging prints, and updated gitignore. CI is now running on…
Jeremuller Jun 1, 2026
e2c5769
Resolved static service using whitenoise and appropriate settings. Ap…
Jeremuller Jun 3, 2026
00a51ee
Updated settings.py doctring
Jeremuller Jun 7, 2026
4377da6
Merge pull request #1 from Jeremuller/prod-preparation
Jeremuller Jun 7, 2026
ccaa015
Resolved quick start problem. USE_SQLITE was pointing at a wrong file.
Jeremuller Jun 12, 2026
b1c6f2a
Merge pull request #2 from Jeremuller/prod-preparation
Jeremuller Jun 12, 2026
1e77e1f
Update pipeline.yml added a second tag "latest" on the image pushed a…
Jeremuller Jun 12, 2026
7ff03dd
Merge pull request #3 from Jeremuller/prod-preparation
Jeremuller Jun 12, 2026
c0acba5
Moved port:8000 into an environement variable to get more adaptabilit…
Jeremuller Jun 15, 2026
ad4c8d3
Merge pull request #4 from Jeremuller/prod-preparation
Jeremuller Jun 15, 2026
1ccd151
Updated ALLOWED_HOSTS for render
Jeremuller Jun 15, 2026
1301a84
Merge pull request #5 from Jeremuller/prod-preparation
Jeremuller Jun 15, 2026
093b096
Creating a starting script to automate migrations and data loading
Jeremuller Jun 21, 2026
1709c11
Merge pull request #6 from Jeremuller/prod-preparation
Jeremuller Jun 21, 2026
38b1c9e
Created a datajson to initialize datas in render postgre service, and…
Jeremuller Jun 21, 2026
a488e62
Merge pull request #7 from Jeremuller/prod-preparation
Jeremuller Jun 21, 2026
a19a4cf
Fixed a minor file name error in start.sh
Jeremuller Jun 21, 2026
4961217
Merge pull request #8 from Jeremuller/prod-preparation
Jeremuller Jun 21, 2026
3271794
Added a third job to pipeline to automate deployment after a successf…
Jeremuller Jun 21, 2026
0f258f0
Merge pull request #9 from Jeremuller/prod-preparation
Jeremuller Jun 21, 2026
d5fd4b6
Testing full pipeline
Jeremuller Jun 21, 2026
cbdd157
Merge pull request #10 from Jeremuller/prod-preparation
Jeremuller Jun 21, 2026
ccc3039
Removing the loading data from the start.sh script
Jeremuller Jun 21, 2026
e551a15
Update README.md
Jeremuller Jun 27, 2026
027cb31
Update README.md
Jeremuller Jun 29, 2026
7421908
Update README.md
Jeremuller Jun 30, 2026
9d956b7
Update README.md
Jeremuller Jun 30, 2026
6f1d28a
Update README.md
Jeremuller Jun 30, 2026
19e5c3c
Update README.md
Jeremuller Jun 30, 2026
d04651e
Merge pull request #11 from Jeremuller/documentation-readme
Jeremuller Jul 1, 2026
a7dd1dc
Updated docker-compose.yml during documentation writing to use start.…
Jeremuller Jul 1, 2026
6c6cdd9
Merge pull request #12 from Jeremuller/master
Jeremuller Jul 1, 2026
7502fe0
Added documentation related libraries in requirements.txt
Jeremuller Jul 3, 2026
b222657
Merge pull request #13 from Jeremuller/prod-preparation
Jeremuller Jul 3, 2026
932c3c5
Initialize Sphinx documentation
Jeremuller Jul 3, 2026
e06a0c8
Added documentation related libraries in requirements.txt
Jeremuller Jul 3, 2026
a2c9e10
Added documentation related libraries in requirements.txt
Jeremuller Jul 3, 2026
1eda955
Started writing sphinx documentation
Jeremuller Jul 4, 2026
876c273
Update README.md
Jeremuller Jul 4, 2026
48acc3f
Started writing sphinx documentation
Jeremuller Jul 4, 2026
05ee026
Update sphinx documentation
Jeremuller Jul 6, 2026
23df1c3
Reviewed docstrings for future autodoc usage.
Jeremuller Jul 7, 2026
77f390f
First setup readthedocs ready
Jeremuller Jul 7, 2026
5d1e864
Added the last part of our sphinx documentation
Jeremuller Jul 7, 2026
563cca8
Deleted useless sphinx extension
Jeremuller Jul 7, 2026
a707b5d
Final documentation reviewing, including minor correction and separat…
Jeremuller Jul 7, 2026
95a0924
Final documentation reviewing, including minor correction and separat…
Jeremuller Jul 7, 2026
62fbeaf
Final documentation reviewing, including minor correction and separat…
Jeremuller Jul 10, 2026
dfa1c60
Final documentation reviewing, including minor correction and separat…
Jeremuller Jul 10, 2026
6bc6583
Final documentation reviewing, including minor correction and separat…
Jeremuller Jul 11, 2026
17f3397
Show off
Jeremuller Jul 11, 2026
ac88223
Show off
Jeremuller Jul 12, 2026
af73fdd
Show off
Jeremuller Jul 12, 2026
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
Binary file added .coverage
Binary file not shown.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
omit =
*/tests/*
*/migrations/*
*/__init__.py
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env
.git
.gitignore
__pycache__/
*.pyc
*.pyo
*.pyd
86 changes: 86 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Pipeline

on:
push:
pull_request:

jobs:
compile:

runs-on: ubuntu-latest

env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
USE_SQLITE: "True"

steps:
# 1. Checkout
- name: Checkout repository
uses: actions/checkout@v4

# 2. Install Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

# 3. Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

# 4. Lint (flake8)
- name: Run flake8
run: flake8 .

# 5. Tests + coverage
- name: Run tests with coverage
run: pytest --cov=. --cov-report=term-missing --cov-fail-under=80


containerize:

needs: compile

if: github.ref == 'refs/heads/master'

runs-on: ubuntu-latest

steps:
# 1. Checkout repository
- name: Checkout repository
uses: actions/checkout@v4

# 2. Login Docker Hub
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

# 3. Build Docker image (SHA + latest)
- name: Build Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/oc_lettings_site:${{ github.sha }} .
docker tag ${{ secrets.DOCKER_USERNAME }}/oc_lettings_site:${{ github.sha }} ${{ secrets.DOCKER_USERNAME }}/oc_lettings_site:latest

# 4. Push Docker images
- name: Push Docker image (SHA)
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/oc_lettings_site:${{ github.sha }}

- name: Push Docker image (latest)
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/oc_lettings_site:latest

deploy:

needs: containerize

if: github.ref == 'refs/heads/master'

runs-on: ubuntu-latest

#Trigger Render deployment
steps:
- name: Trigger Render Deploy Hook
run: curl -X POST ${{ secrets.RENDER_DEPLOY_HOOK }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**/__pycache__
*.pyc
venv
.idea/
.env
*.log
db.sqlite3
docs/build/
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Base image
FROM python:3.10-slim

# Prevent Python from buffering stdout/stderr
ENV PYTHONUNBUFFERED=1

# Set work directory
WORKDIR /app

# Copy requirements first (cache optimization)
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy project
COPY . .

# Collect statics
RUN SECRET_KEY=dummy-secret-key \
USE_SQLITE=true \
python manage.py collectstatic --noinput

# Expose port
EXPOSE 8000

# Run server with start.sh script
RUN chmod +x start.sh

CMD ["./start.sh"]
203 changes: 160 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,168 @@
## Résumé
# Orange County Lettings

Site web d'Orange County Lettings
## Présentation du projet

## Développement local
Orange County Lettings est une application web développée avec Django pour une start-up spécialisée dans la location de biens immobiliers aux États-Unis.

Ce projet a consisté à améliorer une application existante en la restructurant autour d'une architecture Django modulaire et en mettant en place une chaîne d'intégration et de déploiement continus (CI/CD).

La documentation complète du projet est disponible ici :

## Fonctionnalités

L'application permet de consulter les principales informations du service Orange County Lettings à travers une interface web développée avec Django.

Les fonctionnalités disponibles sont les suivantes :

- consultation des annonces immobilières ;
- consultation des profils utilisateurs ;
- accès à l'interface d'administration Django pour la gestion des données.

## Architecture

Le projet est organisé selon une architecture Django modulaire composée de trois applications principales :

- **oc_lettings_site** : configuration générale du projet (settings, routage, serveur WSGI) ;
- **lettings** : gestion des annonces immobilières ;
- **profiles** : gestion des profils utilisateurs.

Cette organisation permet de séparer les responsabilités de chaque composant et facilite la maintenance ainsi que l'évolution de l'application.

L'application est conteneurisée avec Docker et déployée automatiquement via une pipeline CI/CD sur la plateforme Render.

Pour une description détaillée de l'architecture, du déploiement et de l'infrastructure, consultez la documentation complète du projet.

## Stack technique

Le projet s'appuie sur les technologies suivantes :

- **Langage :** Python 3.10
- **Framework :** Django 3.0
- **Bases de données :** SQLite (développement rapide), PostgreSQL (Docker et production)
- **Conteneurisation :** Docker, Docker Compose
- **CI/CD :** GitHub Actions
- **Tests et qualité :** pytest, pytest-django, coverage, flake8, black
- **Monitoring :** Sentry
- **Production :** Gunicorn, WhiteNoise, Render
- **Configuration :** python-dotenv

## Utilisation en local

### Prérequis

- Compte GitHub avec accès en lecture à ce repository
- Git CLI
- SQLite3 CLI
- Interpréteur Python, version 3.6 ou supérieure
Pour exécuter le projet localement, les outils suivants sont nécessaires :

Dans le reste de la documentation sur le développement local, il est supposé que la commande `python` de votre OS shell exécute l'interpréteur Python ci-dessus (à moins qu'un environnement virtuel ne soit activé).
- Git ;
- Python 3.10 ou supérieur ;
- Docker et Docker Compose (optionnel, pour une exécution conteneurisée).

### macOS / Linux
### Installation

#### Cloner le repository
Clonez le dépôt puis installez les dépendances dans un environnement virtuel :

- `cd /path/to/put/project/in`
- `git clone https://github.com/OpenClassrooms-Student-Center/Python-OC-Lettings-FR.git`
```bash
git clone https://github.com/OpenClassrooms-Student-Center/Python-OC-Lettings-FR.git
cd Python-OC-Lettings-FR

#### Créer l'environnement virtuel
python -m venv venv
source venv/bin/activate # Linux / macOS
# ou
venv\Scripts\activate # Windows

- `cd /path/to/Python-OC-Lettings-FR`
- `python -m venv venv`
- `apt-get install python3-venv` (Si l'étape précédente comporte des erreurs avec un paquet non trouvé sur Ubuntu)
- Activer l'environnement `source venv/bin/activate`
- Confirmer que la commande `python` exécute l'interpréteur Python dans l'environnement virtuel
`which python`
- Confirmer que la version de l'interpréteur Python est la version 3.6 ou supérieure `python --version`
- Confirmer que la commande `pip` exécute l'exécutable pip dans l'environnement virtuel, `which pip`
- Pour désactiver l'environnement, `deactivate`
pip install -r requirements.txt
```

#### Exécuter le site
Créez ensuite un fichier .env à la racine du projet et renseignez les variables d'environnement nécessaires.

- `cd /path/to/Python-OC-Lettings-FR`
- `source venv/bin/activate`
- `pip install --requirement requirements.txt`
- `python manage.py runserver`
- Aller sur `http://localhost:8000` dans un navigateur.
- Confirmer que le site fonctionne et qu'il est possible de naviguer (vous devriez voir plusieurs profils et locations).
### Lancement de l'application

#### Linting
#### Avec Django

- `cd /path/to/Python-OC-Lettings-FR`
- `source venv/bin/activate`
- `flake8`
```bash
python manage.py migrate
python manage.py runserver
```

#### Tests unitaires
#### Avec Docker Compose

- `cd /path/to/Python-OC-Lettings-FR`
- `source venv/bin/activate`
- `pytest`
```bash
docker compose up --build
```

L'application est ensuite accessible à l'adresse :

#### Base de données
http://localhost:8000

Pour plus d'informations sur la configuration de l'environnement, les variables d'environnement ou l'utilisation de Docker Compose, consultez la documentation complète.

## Tests et qualité du code

Les principaux outils de qualité peuvent être exécutés depuis la racine du projet :

```bash
flake8 # Analyse statique
pytest # Tests unitaires
pytest --cov # Couverture des tests
```

Ces vérifications sont également exécutées automatiquement par la pipeline CI/CD à chaque `push` et à chaque Pull Request.

## Pipeline CI/CD

Le projet utilise une pipeline GitHub Actions pour automatiser les contrôles qualité, la construction de l'image Docker et le déploiement en production.

```text
Push / Pull Request
GitHub Actions
Job "compile"
├── Installation des dépendances
├── Analyse statique (flake8)
└── Tests unitaires + couverture
└──────────────► Validation réussie
(push sur master uniquement)
Job "containerize"
├── Build Docker
├── Tag SHA
├── Tag latest
└── Push DockerHub
Job "deploy"
Render
```

Les informations sensibles utilisées par la pipeline sont stockées dans les **GitHub Actions Secrets** et ne sont jamais versionnées dans le dépôt.

## Déploiement

L'application est déployée automatiquement sur **Render** à partir de la pipeline GitHub Actions.

Lorsqu'un changement est fusionné sur la branche `master`, la pipeline :

1. construit une image Docker ;
2. publie cette image sur Docker Hub ;
3. déclenche le déploiement sur Render via un Deploy Hook.

Au démarrage du conteneur, le script `start.sh` applique automatiquement les migrations Django avant de lancer le serveur Gunicorn.

L'application s'exécute en production avec une base de données PostgreSQL managée par Render. L'ensemble de la configuration est assuré au moyen de variables d'environnement et le service est vérifié automatiquement par le mécanisme de **Health Check** de Render.

## Autres commandes utiles

### Base de données

- `cd /path/to/Python-OC-Lettings-FR`
- Ouvrir une session shell `sqlite3`
Expand All @@ -64,14 +173,22 @@ Dans le reste de la documentation sur le développement local, il est supposé q
Python-OC-Lettings-FR_profile where favorite_city like 'B%';`
- `.quit` pour quitter

#### Panel d'administration
### Panel d'administration

- Aller sur `http://localhost:8000/admin`
- Connectez-vous avec l'utilisateur `admin`, mot de passe `Abc1234!`

### Windows
## Liens utiles

Les documentations officielles suivantes permettent d'approfondir les technologies utilisées dans ce projet :

- GitHub : https://docs.github.com/fr
- Docker : https://docs.docker.com/
- GitHub Actions : https://docs.github.com/fr/actions
- Render : https://render.com/docs

## Auteur

Utilisation de PowerShell, comme ci-dessus sauf :
Jérémy Muller, étudiant en développement applicatif python chez OpenClassrooms.

- Pour activer l'environnement virtuel, `.\venv\Scripts\Activate.ps1`
- Remplacer `which <my-command>` par `(Get-Command <my-command>).Path`
GitHub : https://github.com/Jeremuller/
Loading