Merge pull request 'j3/fix/refactor/routes' (#179) from j3/fix/refactor/routes into dev
Reviewed-on: https://10.4.0.131/gitea/DI1-P4-E1/Webzine/pulls/179 Reviewed-by: j.vetu <josephine.vetu@diiage.org>
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
{
|
||||
<tr class="align-middle">
|
||||
<td>
|
||||
<a asp-action="Details" asp-controller="Titre" asp-route-id="@commentaire.Titre.IdTitre">
|
||||
<a asp-controller="Titre" asp-action="Index" asp-route-id="@commentaire.Titre.IdTitre">
|
||||
@commentaire.Titre.Libelle
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<div class="col-md-4">
|
||||
<a asp-area=""
|
||||
asp-controller="Titre"
|
||||
asp-action="Details"
|
||||
asp-action="Index"
|
||||
asp-route-id="@Model.IdMusiqueLaPlusJouee">
|
||||
<div class="ratio ratio-4x3">
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
/// </summary>
|
||||
/// <param name="nom">Le nom de l'artiste à rechercher, formaté en kebab-case (ex: "fatal-bazooka").</param>
|
||||
/// <returns>La vue de l'artiste avec son ViewModel, ou une redirection vers l'accueil si le nom est vide, ou une erreur 404 si l'artiste n'est pas trouvé.</returns>
|
||||
[HttpGet("/artiste/{nom}")]
|
||||
public IActionResult Index(string nom)
|
||||
{
|
||||
this.logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Webzine.WebApplication.Controllers
|
||||
/// Affichage de la page Recherche depuis le header de l'app.
|
||||
/// </summary>
|
||||
/// <param name="mot">Nom d'artiste ou de titre.</param>
|
||||
/// <returns>Page de recherche avec les résultats.</returns>
|
||||
/// <returns>Page de recherche avec les r<EFBFBD>sultats.</returns>
|
||||
public IActionResult Index(string mot)
|
||||
{
|
||||
// Logger la recherche.
|
||||
@@ -41,7 +41,7 @@ namespace Webzine.WebApplication.Controllers
|
||||
// Recherche des artistes.
|
||||
var artistes = this.artisteRepository.Search(mot);
|
||||
|
||||
// Paramètres a retourner à la vue.
|
||||
// Param<EFBFBD>tres a retourner <EFBFBD> la vue.
|
||||
var vm = new RechercheIndexViewModel
|
||||
{
|
||||
Mot = mot,
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Webzine.WebApplication.Controllers
|
||||
/// affichage des details, filtrage par style,
|
||||
/// ajout de likes, commentaires et recherche.
|
||||
/// </summary>
|
||||
[Route("titre")]
|
||||
public class TitreController : Controller
|
||||
{
|
||||
private readonly ILogger<TitreController> logger;
|
||||
@@ -40,8 +39,8 @@ namespace Webzine.WebApplication.Controllers
|
||||
/// </summary>
|
||||
/// <param name="id">Identifiant du titre.</param>
|
||||
/// <returns>Vue des details ou 404 si introuvable.</returns>
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult Details(int id)
|
||||
|
||||
public IActionResult Index(int id)
|
||||
{
|
||||
this.logger.LogInformation("Demande d'affichage du detail pour le titre ID {Id}.", id);
|
||||
|
||||
@@ -82,7 +81,6 @@ namespace Webzine.WebApplication.Controllers
|
||||
/// </summary>
|
||||
/// <param name="style">Nom du style musical.</param>
|
||||
/// <returns>Vue contenant la liste filtree.</returns>
|
||||
[HttpGet("style/{style}")]
|
||||
public IActionResult Style(string style)
|
||||
{
|
||||
this.logger.LogInformation("Recherche des titres pour le style : {Style}.", style);
|
||||
@@ -103,7 +101,7 @@ namespace Webzine.WebApplication.Controllers
|
||||
/// </summary>
|
||||
/// <param name="model">Modele contenant l'identifiant du titre.</param>
|
||||
/// <returns>Redirection vers la page detail.</returns>
|
||||
[HttpPost("like")]
|
||||
[HttpPost]
|
||||
public IActionResult Like(TitreLike model)
|
||||
{
|
||||
this.logger.LogInformation("Ajout d'un like pour le titre ID {Id}.", model.IdTitre);
|
||||
@@ -126,7 +124,7 @@ namespace Webzine.WebApplication.Controllers
|
||||
/// </summary>
|
||||
/// <param name="model">Donnees du commentaire.</param>
|
||||
/// <returns>Redirection vers la page detail.</returns>
|
||||
[HttpPost("comment")]
|
||||
[HttpPost]
|
||||
public IActionResult Comment(TitreComment model)
|
||||
{
|
||||
if (!this.ModelState.IsValid)
|
||||
|
||||
@@ -7,6 +7,41 @@ public static class RouteConfiguration
|
||||
/// </summary>
|
||||
public static void MapCustomRoutes(this IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
// ----------- TITRE -----------
|
||||
endpoints.MapControllerRoute(
|
||||
name: "TitreStyle",
|
||||
pattern: "titres/style/{style}",
|
||||
defaults: new { controller = "Titre", action = "Style" });
|
||||
|
||||
endpoints.MapControllerRoute(
|
||||
name: "TitreIndex",
|
||||
pattern: "titre/{id}",
|
||||
defaults: new { controller = "Titre", action = "Index" });
|
||||
|
||||
endpoints.MapControllerRoute(
|
||||
name: "ArtisteIndex",
|
||||
pattern: "artiste/{nom}",
|
||||
defaults: new { controller = "Artiste", action = "Index" });
|
||||
|
||||
|
||||
// ----------- ADMIN -----------
|
||||
|
||||
var adminRoutes = new Dictionary<string, string>
|
||||
{
|
||||
{ "artistes", "Artiste" }, { "commentaires", "Commentaire" }, { "styles", "Style" }, { "titres", "Titre" },
|
||||
};
|
||||
|
||||
foreach (var route in adminRoutes)
|
||||
{
|
||||
endpoints.MapControllerRoute(
|
||||
name: $"Admin{route.Value}Index",
|
||||
pattern: $"administration/{route.Key}",
|
||||
defaults: new { area = "Administration", controller = route.Value, action = "Index" });
|
||||
}
|
||||
|
||||
|
||||
// --- AUTRE PROUTES ---
|
||||
|
||||
endpoints.MapControllerRoute(
|
||||
name: "areas",
|
||||
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
@titre.Artiste.Nom
|
||||
</a>
|
||||
-
|
||||
<a asp-action="Details"
|
||||
<a asp-action="Index"
|
||||
asp-controller="Titre"
|
||||
asp-route-id="@titre.IdTitre">
|
||||
@titre.Libelle
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="d-flex flex-wrap align-items-center gap-3">
|
||||
<a asp-action="Details"
|
||||
<a asp-action="Index"
|
||||
asp-controller="Titre"
|
||||
asp-route-id="@titre.IdTitre"
|
||||
class="btn btn-primary btn-sm">
|
||||
@@ -90,7 +90,7 @@
|
||||
<img class="card-img-top" src="@titre.UrlJaquette" alt="@titre.Album" loading="lazy" />
|
||||
|
||||
<div class="card-body">
|
||||
<a asp-controller="Titre" asp-action="Details" asp-route-id="@titre.IdTitre" class="card-link">
|
||||
<a asp-controller="Titre" asp-action="Index" asp-route-id="@titre.IdTitre" class="card-link">
|
||||
@titre.Libelle
|
||||
</a>
|
||||
<br />
|
||||
|
||||
@@ -56,7 +56,7 @@ else
|
||||
<td class="text-secondary font-monospace">@dureeFormatee</td>
|
||||
<td>
|
||||
<a asp-controller="Titre"
|
||||
asp-action="Details"
|
||||
asp-action="Index"
|
||||
asp-route-id="@titre.IdTitre"
|
||||
class="text-primary">
|
||||
@titre.Libelle
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
@if (!Model.Artistes.Any())
|
||||
{
|
||||
<div class="alert alert-info">
|
||||
<p>Aucun artiste n'a été trouvé.</p>
|
||||
<p>Aucun artiste n'a été trouvé.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
@if (!Model.Titres.Any())
|
||||
{
|
||||
<div class="alert alert-info">
|
||||
<p>Aucun titre n'a été trouvé.</p>
|
||||
<p>Aucun titre n'a été trouvé.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
{
|
||||
<div class="d-flex align-items-start my-3">
|
||||
<a asp-controller="Titre"
|
||||
asp-action="Details"
|
||||
asp-action="Index"
|
||||
asp-route-id="@titre.IdTitre"
|
||||
class="me-3 text-black">
|
||||
<img src="@titre.UrlJaquette" alt="@titre.Libelle" width="70" height="70" class="object-fit-cover" loading="lazy" />
|
||||
@@ -58,7 +58,7 @@
|
||||
</a>
|
||||
-
|
||||
<a asp-controller="Titre"
|
||||
asp-action="Details"
|
||||
asp-action="Index"
|
||||
asp-route-id="@titre.IdTitre">
|
||||
@titre.Libelle
|
||||
</a>
|
||||
|
||||
@@ -131,7 +131,7 @@ info "── Titre – Par style ───────────────
|
||||
STYLES=("Rock" "Pop" "Rap" "Jazz" "Metal" "Electronic" "Hip-Hop" "Soul" "Funk")
|
||||
for STYLE in "${STYLES[@]}"; do
|
||||
ENCODE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$STYLE'))" 2>/dev/null || echo "$STYLE")
|
||||
verifier_endpoint GET "$BASE_URL/titre/style/$ENCODE" "GET /titre/style/$STYLE"
|
||||
verifier_endpoint GET "$BASE_URL/titres/style/$ENCODE" "GET /titres/style/$STYLE"
|
||||
done
|
||||
|
||||
log ""
|
||||
@@ -160,26 +160,26 @@ verifier_endpoint GET "$BASE_URL/Administration/Dashboard" "GET /A
|
||||
|
||||
log ""
|
||||
info "── Administration – Artiste ──────────────────────────────"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste" "GET /Administration/Artiste (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Artistes" "GET /Administration/Artistes (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Create" "GET /Administration/Artiste/Create"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Edit/1" "GET /Administration/Artiste/Edit/1"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Delete/1" "GET /Administration/Artiste/Delete/1"
|
||||
|
||||
log ""
|
||||
info "── Administration – Commentaire ──────────────────────────"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Commentaire" "GET /Administration/Commentaire (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Commentaires" "GET /Administration/Commentaires (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Commentaire/Delete/1" "GET /Administration/Commentaire/Delete/1"
|
||||
|
||||
log ""
|
||||
info "── Administration – Style ────────────────────────────────"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Style" "GET /Administration/Style (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Styles" "GET /Administration/Styles (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Create" "GET /Administration/Style/Create"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Edit/1" "GET /Administration/Style/Edit/1"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Delete/1" "GET /Administration/Style/Delete/1"
|
||||
|
||||
log ""
|
||||
info "── Administration – Titre ────────────────────────────────"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Titre" "GET /Administration/Titre (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Titres" "GET /Administration/Titres (liste)"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Create" "GET /Administration/Titre/Create"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Edit/1" "GET /Administration/Titre/Edit/1"
|
||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Delete/1" "GET /Administration/Titre/Delete/1"
|
||||
|
||||
Reference in New Issue
Block a user