This repository has been archived by the owner on Aug 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from datetime import datetime | ||
from dateutil.tz import tzlocal | ||
from django.contrib.syndication.views import Feed | ||
from django.urls import reverse | ||
from news.models import Post | ||
|
||
|
||
class LatestPosts(Feed): | ||
title = "TTS Office of Acquisitions Updates" | ||
link = "/news/" | ||
description = "Updates from the TTS Office of Acquisitions team about "\ | ||
"experiments, buys, events, and more" | ||
|
||
def items(self): | ||
return Post.objects.filter( | ||
draft=False, | ||
publication_date__lte=datetime.now(tzlocal()), | ||
).order_by('publication_date')[:20] | ||
|
||
def item_title(self, item): | ||
return item.title | ||
|
||
def item_description(self, item): | ||
return item.content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from django.conf.urls import include, url | ||
from news import views | ||
from news.feeds import LatestPosts | ||
|
||
urlpatterns = [ | ||
url(r'^$', views.posts, name='posts'), | ||
url(r'^rss/$', LatestPosts()), | ||
url(r'^(?P<slug>[a-z\-]+)$', views.post, name='post'), | ||
] |