diff --git a/WSR/static/scss/components.scss b/WSR/static/scss/components.scss index 17b30f014318f86f24ab0a52602152e63eb8d747..05959052e1e4d0b5831cb5fd780eced2bb4b88aa 100644 --- a/WSR/static/scss/components.scss +++ b/WSR/static/scss/components.scss @@ -167,19 +167,19 @@ padding: 32px 24px; background-color: $white; width: 1076px; - - .news-cards { - display: grid; - grid-template-columns: repeat(3, 1fr); - gap: map-get($spacers, 3); - } } } +.news-cards { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: map-get($spacers, 3); +} + .news-card { display: flex; flex-direction: column; - width: 332px; + width: auto; text-decoration: none; color: $black; @@ -260,6 +260,7 @@ footer { color: $white; font-size: 1.4rem; } + .desc { color: $light-gray; line-height: 1; @@ -298,6 +299,7 @@ footer { filter: brightness(0); } } + .desc { color: $dark-gray; } diff --git a/WSR/templates/articles.html b/WSR/templates/articles.html new file mode 100644 index 0000000000000000000000000000000000000000..5a82e97078c81ec2cefdd506b032e8f3f4fa427e --- /dev/null +++ b/WSR/templates/articles.html @@ -0,0 +1,29 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %}WSR - Liste des articles{% endblock %} + +{% block content %} + <div class="container mt-4"> + <div class="p-4 bg-white"> + <h4 class="eurostile title">Articles de blog</h4> + <p>Reste informé de toutes les actualités des WSR ! (déso j'ai pas d'idées, il est tard)</p> + + <div class="news-cards"> + {% for article in articles %} + <a class="news-card" href="{% url 'article' id=article.id %}"> + <div class="header"> + <div class="logo"> + <img src="{% static 'images/WSR.png' %}" alt="Logo WSR"> + </div> + </div> + <div class="mt-3"> + <div class="eurostile">{{ article.title }}</div> + <div class="desc">{{ article.summary }}</div> + </div> + </a> + {% endfor %} + </div> + </div> + </div> +{% endblock %} \ No newline at end of file diff --git a/WSR/templates/base.html b/WSR/templates/base.html index 1d17f3d78f188056afc37e674250e9e95965e494..a3c8980352cdc7816855fa6d08b874a4926790ae 100644 --- a/WSR/templates/base.html +++ b/WSR/templates/base.html @@ -13,7 +13,7 @@ </head> <body> <header class="container"> - <a class="logo" href="/"> + <a class="logo" href="{% url 'home' %}"> <img src="{% static 'images/WSR.png' %}" alt="Logo WSR"> </a> <nav class="navbar"> diff --git a/WSR/templates/home.html b/WSR/templates/home.html index 573246c0f4a2683287b9b41f1475525bd847d0c3..e0011c7d8d0379dc49d60fe9e75af6f4c18048f5 100644 --- a/WSR/templates/home.html +++ b/WSR/templates/home.html @@ -83,7 +83,7 @@ {% endfor %} </div> <div class="d-flex justify-content-end"> - <a class="btn" href="#">Voir tout</a> + <a class="btn" href="{% url 'articles' %}">Voir tout</a> </div> </div> <div id="racesResultsContainer" style="display: none;"> diff --git a/WSR/views.py b/WSR/views.py index fbad81c5d35154b8a9b49555bebc49c45f6e3550..7d08e50973324bc4cc62ed00ae70f7e1b892e0d3 100644 --- a/WSR/views.py +++ b/WSR/views.py @@ -64,6 +64,20 @@ def home(request): ) +def articles(request): + articles = Article.objects.order_by('-publication_date').all() + for article in articles: + article.summary = ' '.join(article.content.split()[:14]) + '...' + + return render( + request, + 'articles.html', + { + "articles": articles + } + ) + + def view_article(request, id): article = Article.objects.get(id=id) md = markdown.Markdown() diff --git a/WSR_website/urls.py b/WSR_website/urls.py index 4779a3221d32e63fcc592455178992e6f272d5ce..ed103128d5291601c07c09e4f8780ea452271c99 100644 --- a/WSR_website/urls.py +++ b/WSR_website/urls.py @@ -25,6 +25,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', views.home, name="home"), path('article/<int:id>', views.view_article, name="article"), + path('articles', views.articles, name="articles"), path('races-types', views.races_types, name="races_types"), path('vehicles', views.vehicles, name="vehicles"), path('seasons', views.seasons, name="seasons")