Manage articles, comments and replies#16
Merged
Conversation
+ 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.
1077d4c to
5a7b70a
Compare
…align with the new structure and centralize business logic in the model
d591954 to
868c6c5
Compare
…e model and refactor to a Model–View–Controller–Service (MVCS) architecture by introducing a Service layer to encapsulate all business logic
…n the controllers
…vice layer and optimize SQLAlchemy queries
…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
…m "auth" to "login"
…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
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.