Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSS feed titles and descriptions are now not terrible. #3123

Merged
merged 3 commits into from
Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions src/rss/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@


class LatestNewsFeed(Feed):
title = "News"
link = "/news/"
description = "Updates on changes and additions to police beat central."

def get_object(self, request, *args, **kwargs):

return request.journal if request.journal else request.press

def title(self, obj):
return "{} News Feed".format(obj.name)

def description(self, obj):
return "A feed of the 10 latest news items from {}".format(obj.name)

def items(self, obj):
content_type = ContentType.objects.get_for_model(obj)
return comms_models.NewsItem.objects.filter(
Expand Down Expand Up @@ -51,18 +54,30 @@ def item_link(self, item):


class LatestArticlesFeed(Feed):
title = "Articles"
link = "/articles/"
description = "Updates on changes and additions to police beat central."

def get_object(self, request, *args, **kwargs):
return request.journal
return request.journal or request.press

def title(self, obj):
return "{} Article Feed".format(obj.name)

def description(self, obj):
return "A feed of the 10 latest articles from {}".format(obj.name)

def items(self, obj):
return submission_models.Article.objects.filter(
date_published__lte=timezone.now(),
journal=obj
).order_by('-date_published')[:10]
try:
return submission_models.Article.objects.filter(
date_published__lte=timezone.now(),
journal=obj
).order_by('-date_published')[:10]
except ValueError:
return submission_models.Article.objects.filter(
date_published__lte=timezone.now(),
journal__press=obj,
journal__hide_from_press=False,
).order_by('-date_published')[:10]


def item_title(self, item):
return striptags(item.title)
Expand Down