Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
75c766ec
Verified
Commit
75c766ec
authored
Sep 11, 2017
by
Thibaut Broggi
Browse files
Add filter by tag for RSS feed
parent
f20c705f
Changes
2
Hide whitespace changes
Inline
Side-by-side
apps/rp/feeds/feeds.py
View file @
75c766ec
...
...
@@ -31,3 +31,13 @@ class ArticlesFeed(Feed):
def
item_categories
(
self
,
item
):
return
item
.
tags
.
all
()
class
ArticlesTagsFeed
(
ArticlesFeed
):
def
__init__
(
self
,
**
kwargs
):
pass
def
items
(
self
):
return
Article
.
objects
.
filter
(
tags__name__in
=
[
self
.
filter_tag
])[:
25
]
def
get_object
(
self
,
request
,
filter_tag
):
self
.
filter_tag
=
filter_tag
apps/rp/feeds/urls.py
View file @
75c766ec
from
django.conf.urls
import
url
from
.feeds
import
ArticlesFeed
from
.feeds
import
ArticlesFeed
,
ArticlesTagsFeed
urlpatterns
=
[
url
(
r
'^$'
,
ArticlesFeed
(
filter_lang
=
'FR'
),
name
=
'articles-feed'
),
url
(
r
'^international$'
,
ArticlesFeed
(
filter_lang
=
'EN'
),
name
=
'articles-feed-international'
)
url
(
r
'^international$'
,
ArticlesFeed
(
filter_lang
=
'EN'
),
name
=
'articles-feed-international'
),
url
(
r
'^by-tag/(?P<filter_tag>.*)'
,
ArticlesTagsFeed
())
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment