Skip to content
Snippets Groups Projects
Commit 661d7cbf authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

Création de la page des articles.

parent 4404fb1d
No related branches found
No related tags found
No related merge requests found
......@@ -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-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;
}
......
{% 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
......@@ -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">
......
......@@ -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;">
......
......@@ -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()
......
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment