Skip to content
Draft
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions src/website/webview/feeds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from django.contrib.syndication.views import Feed
from django.urls import reverse
from django.utils.feedgenerator import Atom1Feed

from shared.models import NixpkgsIssue


class RssNixpkgsIssueFeed(Feed):
description_template = "templates/issue_feed.html"

def get_object(self, request, code):
return NixpkgsIssue.objects.get(code=code)

def title(self, obj):
return "Issue %s" % obj.code

def link(self, obj):
# TODO: make the class compatible with get_absolute_url
# return obj.get_absolute_url()
return reverse("webview:issue_detail", args=[obj.code])

def item_link(self, obj):
return reverse("webview:issue_detail", args=[obj.code])

def description(self, obj):
return "Recent update for issue %s" % obj.code

def items(self, obj):
return NixpkgsIssue.objects.filter(code=obj.code).order_by("code")[:30]


class AtomNixpkgsIssueFeed(RssNixpkgsIssueFeed):
feed_type = Atom1Feed
subtitle = RssNixpkgsIssueFeed.description
1 change: 1 addition & 0 deletions src/website/webview/templates/issue_feed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ obj.description }}
11 changes: 11 additions & 0 deletions src/website/webview/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.urls import path, re_path

from webview.views import HomeView, NixpkgsIssueView, NixpkgsIssueListView
from webview.feeds import AtomNixpkgsIssueFeed, RssNixpkgsIssueFeed # type: ignore

app_name = "webview"

Expand All @@ -13,4 +14,14 @@
NixpkgsIssueView.as_view(),
name="issue_detail",
),
re_path(
r"^issues/(?P<code>NIXPKGS-[0-9]{4}-[0-9]{4,19})/rss/$",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use the converter here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there was a code version with a converter and it got reverted. In the final PR, these paths will use it.

RssNixpkgsIssueFeed(),
name="issue_feed_rss",
),
re_path(
r"^issues/(?P<code>NIXPKGS-[0-9]{4}-[0-9]{4,19})/atom/$",
AtomNixpkgsIssueFeed(),
name="issue_feed_atom",
),
]