Commit e1ec9aef authored by cynddl's avatar cynddl

Filter by French/international newspapers

parent cc2b9190
Pipeline #1156 passed with stages
in 2 minutes and 9 seconds
......@@ -23,8 +23,28 @@
<div class="col-md-10 offset-1">
<ul class="nav nav-compressed my-4">
{% if view.filter_lang == 'EN' %}
<li class="nav-item">
<a class="nav-link active" href="#">
<a class="nav-link" href="{% url 'rp:public-article-list' %}">
<span class="fa-stack fa-md">
<i class="fa fa-circle-thin fa-stack-2x"></i>
<i class="fa fa-map-marker fa-stack-1x"></i>
</span>
Presse francophone
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="{% url 'rp:public-article-list-international' %}">
<span class="fa-stack fa-md">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-globe fa-stack-1x color-white"></i>
</span>
Presse internationale
</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link active" href="{% url 'rp:public-article-list' %}">
<span class="fa-stack fa-md">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-map-marker fa-stack-1x color-white"></i>
......@@ -33,7 +53,7 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<a class="nav-link" href="{% url 'rp:public-article-list-international' %}">
<span class="fa-stack fa-md">
<i class="fa fa-circle-thin fa-stack-2x"></i>
<i class="fa fa-globe fa-stack-1x"></i>
......@@ -41,6 +61,8 @@
Presse internationale
</a>
</li>
{% endif %}
<li class="nav-item ml-auto">
<a class="nav-link disabled" href="#">
......
......@@ -6,9 +6,14 @@ from rp.views.articles import ArticleListFlux, ArticleEdit, ArticleDetailView, A
urlpatterns = [
url(
r"^$",
ArticleList.as_view(),
ArticleList.as_view(filter_lang='FR'),
name="public-article-list"
),
url(
r"^international$",
ArticleList.as_view(filter_lang='EN'),
name="public-article-list-international"
),
url(
r"^article/list/(?P<filter_view>\w+)",
login_required(ArticleListFlux.as_view()),
......
......@@ -19,11 +19,24 @@ from rp.models import Article
from .votes import UDList
class ArticleList(ListView):
model = Article
paginate_by = 10
template_name = "rp/article_list_public.html"
filter_lang = None
def get_queryset(self):
if self.filter_lang in ["EN", "FR"]:
qs = Article.objects.filter(lang=self.filter_lang)
else:
qs = Article.objects.filter()
return qs.order_by('-created_at')
#
# def get_context_data(self, **kwargs):
# context = super().get_context_data(**kwargs)
# context["filter_lang"] = self.filter_lang
# return context
class ArticleListFlux(UDList):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment