From 4404fb1d2d919bae6cb12d7417ca3b7372fd0320 Mon Sep 17 00:00:00 2001 From: SofianeLasri <alasri250@gmail.com> Date: Tue, 13 Jun 2023 22:50:00 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20de=20la=20page=20article.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WSR/static/scss/app.scss | 20 ++++++++++++++++++++ WSR/static/scss/components.scss | 11 ++++++----- WSR/templates/article.html | 21 +++++++++++++++++++++ WSR/templates/home.html | 4 ++-- WSR/views.py | 12 ++++++++++-- 5 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 WSR/templates/article.html diff --git a/WSR/static/scss/app.scss b/WSR/static/scss/app.scss index 7e8320d..1e70f05 100644 --- a/WSR/static/scss/app.scss +++ b/WSR/static/scss/app.scss @@ -69,6 +69,11 @@ body { backdrop-filter: blur(8px); } +a { + color: $red; + text-decoration: none; +} + // Other header { display: flex; @@ -88,4 +93,19 @@ header { width: auto; height: auto; } +} + +.article-container { + .meta { + color: $dark-gray; + font-size: 0.9rem; + } + + .article-content { + margin-top: map-get($spacers, 5); + } + + h1, h2, h3, h4, h5, h6 { + @extend .eurostile; + } } \ No newline at end of file diff --git a/WSR/static/scss/components.scss b/WSR/static/scss/components.scss index c516308..17b30f0 100644 --- a/WSR/static/scss/components.scss +++ b/WSR/static/scss/components.scss @@ -180,6 +180,12 @@ display: flex; flex-direction: column; width: 332px; + text-decoration: none; + color: $black; + + &:hover { + color: $red; + } .header { display: flex; @@ -215,11 +221,6 @@ footer { padding-bottom: 24px; border-top: 4px solid $dark-gray; color: $light-gray; - - a { - color: $red; - text-decoration: none; - } } .cars-showcase { diff --git a/WSR/templates/article.html b/WSR/templates/article.html new file mode 100644 index 0000000..d94b44b --- /dev/null +++ b/WSR/templates/article.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %}WSR - {{ article.title }}{% endblock %} + +{% block content %} + <div class="container mt-4"> + <div class="p-4 bg-white article-container"> + <h4>{{ article.title }}</h4> + <div class="meta"> + <span>PubliƩ par </span><a href="#">WSR CM</a> le {{ article.publication_date|date:"d/m/Y" }} + </div> + + <div class="article-content"> + {% autoescape off %} + {{ article.content }} + {% endautoescape %} + </div> + </div> + </div> +{% endblock %} \ No newline at end of file diff --git a/WSR/templates/home.html b/WSR/templates/home.html index dfc90b0..573246c 100644 --- a/WSR/templates/home.html +++ b/WSR/templates/home.html @@ -69,7 +69,7 @@ <div class="news-cards"> {% for article in six_last_articles %} - <div class="news-card"> + <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"> @@ -79,7 +79,7 @@ <div class="eurostile">{{ article.title }}</div> <div class="desc">{{ article.summary }}</div> </div> - </div> + </a> {% endfor %} </div> <div class="d-flex justify-content-end"> diff --git a/WSR/views.py b/WSR/views.py index d86d7e3..fbad81c 100644 --- a/WSR/views.py +++ b/WSR/views.py @@ -65,8 +65,16 @@ def home(request): def view_article(request, id): - article = Article.objects.get(id) - return None + article = Article.objects.get(id=id) + md = markdown.Markdown() + article.content = md.convert(article.content) + return render( + request, + 'article.html', + { + "article": article + } + ) def races_types(request): -- GitLab