Skip to content

Manage articles, comments and replies#16

Merged
hlargitte merged 18 commits intomasterfrom
manage-articles-comments-replies
Feb 27, 2026
Merged

Manage articles, comments and replies#16
hlargitte merged 18 commits intomasterfrom
manage-articles-comments-replies

Conversation

@hlargitte
Copy link
Owner

@hlargitte hlargitte commented Feb 12, 2026

La modification apportée dans ce code consiste à gérer la création d’articles, leur affichage sous forme de liste, ainsi que la possibilité d’ajouter des commentaires et d’y répondre.

Voici les modifications qui ont été apportées en plus de celles citées précédemment :

  • La page d’accueil a été modifiée : ce n’est plus la page de connexion, mais la page affichant la liste des articles.

  • L’architecture MVC devient MVCS (Model, View, Controller, Service), où la couche service contient désormais la logique métier.

  • Les requêtes ont dû être optimisées en conséquence, avec plusieurs ajustements sur les requêtes SQLAlchemy.

  • Les blocs "with session" ne sont plus utilisés, car nous avons appliqué le design pattern Unit of Work. Celui-ci regroupe les opérations de base de données d’une action dans une seule transaction cohérente. Dans notre cas, cela garantit qu’une requête HTTP utilise une seule session SQLAlchemy propre, et non plusieurs.

  • Les requêtes SQL ont été optimisées pour éliminer les problèmes de N+1 lors du chargement des commentaires, et une limite de profondeur à deux niveaux a été imposée pour améliorer la lisibilité du rendu.

  • Les pages d’index et de détail des articles ont été améliorées.

  • L’affichage des articles est limité à 10 par page ; au-delà, la navigation passe automatiquement à la page suivante.

+ Replaced the old login‑based home page with a new homepage displaying the list of blog articles, and added a dedicated tab to access the login page.

+ Updated role permissions so admins and authors can create, read and update articles, while users and non‑authenticated visitors have read‑only access.

+ Admins can delete all articles, while authors can only delete their own articles.

+ All authenticated roles can post comments, and the admin can delete any comment.
@hlargitte hlargitte self-assigned this Feb 12, 2026
@raynaldlao raynaldlao force-pushed the manage-articles-comments-replies branch from 1077d4c to 5a7b70a Compare February 24, 2026 11:29
…align with the new structure and centralize business logic in the model
@raynaldlao raynaldlao force-pushed the manage-articles-comments-replies branch from d591954 to 868c6c5 Compare February 24, 2026 15:23
…e model and refactor to a Model–View–Controller–Service (MVCS) architecture by introducing a Service layer to encapsulate all business logic
…n each service, adopt a request‑scoped Unit of Work via scoped_session, and reduce unnecessary database connections
…nate N+1 issues in comment loading, enforce a two‑level nesting limit for clearer rendering and apply structural and visual improvements to article_detail.html
… the home view and apply structural and visual improvements to index.html
…ring and add a comment indicating where an exception should be introduced
…it models into separate files, add controller suffix for easier discovery and add missing __init__.py files
…successful route execution with db_session.commit()
…t_article by having the service return the updated entity
…date the application code to make them pass and improve conftest.py
…etter mirror the models folder structure, and add new service tests
@raynaldlao raynaldlao self-requested a review February 27, 2026 20:27
@raynaldlao raynaldlao self-assigned this Feb 27, 2026
@raynaldlao raynaldlao requested review from raynaldlao and removed request for raynaldlao February 27, 2026 20:27
@hlargitte hlargitte merged commit fd8b1e3 into master Feb 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants