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

feat: RSS feed for I-Ds #7149

Merged
merged 5 commits into from
Nov 15, 2024
Merged
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
32 changes: 28 additions & 4 deletions ietf/doc/feeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2020, All Rights Reserved
# Copyright The IETF Trust 2007-2024, All Rights Reserved
# -*- coding: utf-8 -*-

import debug # pyflakes:ignore
Expand All @@ -18,7 +18,7 @@
from django.utils import timezone
from django.utils.html import strip_tags

from ietf.doc.models import Document, State, LastCallDocEvent, DocEvent
from ietf.doc.models import Document, State, LastCallDocEvent, DocEvent, NewRevisionDocEvent
from ietf.doc.utils import augment_events_with_revision
from ietf.doc.templatetags.ietf_filters import format_textarea
from ietf.utils.timezone import RPC_TZINFO
Expand Down Expand Up @@ -76,7 +76,7 @@ def item_description(self, item):
truncatewords_html(format_textarea(item.desc), 20)
)

def item_pubdate(self, item):
def item_updateddate(self, item):
return item.time

def item_author_name(self, item):
Expand Down Expand Up @@ -123,10 +123,34 @@ def item_title(self, item):
def item_description(self, item):
return strip_control_characters(linebreaks(item.lc_event.desc))

def item_pubdate(self, item):
def item_updateddate(self, item):
return item.lc_event.time


class DraftFeed(Feed):
title = "Internet-Drafts"
feed_type = Atom1Feed
author_name = "IESG Secretary"
link ="/doc/recent/"

def items(self):
since = timezone.now() - datetime.timedelta(days=7)
state = State.objects.get(type='draft', slug='active')
events = NewRevisionDocEvent.objects.filter(time__gt=since)
names = [ e.doc.name for e in events ]
docs = Document.objects.filter(name__in=names, states=state).order_by("-time")
return docs

def item_title(self, item):
return "%s : %s" % (item.name, item.title)

def item_description(self, item):
return item.abstract

def item_updateddate(self, item):
return item.time


class Rss201WithNamespacesFeed(Rss201rev2Feed):
def root_attributes(self):
attrs = super(Rss201WithNamespacesFeed, self).root_attributes()
Expand Down
14 changes: 14 additions & 0 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,20 @@ def test_last_call_feed(self):
self.assertEqual(r.status_code, 200)
self.assertContains(r, doc.name)

def test_draft_feed(self):
doc = WgDraftFactory()
doc.docevent_set.filter(newrevisiondocevent__isnull=False).update(time=timezone.now())
StateDocEventFactory(doc=doc, time=timezone.now())

old = WgDraftFactory()
old.docevent_set.filter(newrevisiondocevent__isnull=False).update(time=timezone.now()-datetime.timedelta(days=8))
StateDocEventFactory(doc=old, time=timezone.now()-datetime.timedelta(days=8))

r = self.client.get("/feed/draft/")
self.assertEqual(r.status_code, 200)
self.assertContains(r, doc.name)
self.assertNotContains(r, old.name)

def test_rfc_feed(self):
rfc = WgRfcFactory(rfc_number=9000)
DocEventFactory(doc=rfc, type="published_rfc")
Expand Down
5 changes: 4 additions & 1 deletion ietf/feed_urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright The IETF Trust 2007-2024, All Rights Reserved

from django.views.generic import RedirectView
from django.conf import settings

from ietf.doc.feeds import DocumentChangesFeed, InLastCallFeed, RfcFeed
from ietf.doc.feeds import DocumentChangesFeed, InLastCallFeed, RfcFeed, DraftFeed
from ietf.group.feeds import GroupChangesFeed
from ietf.iesg.feeds import IESGAgendaFeed
from ietf.ipr.feeds import LatestIprDisclosuresFeed
Expand All @@ -20,4 +22,5 @@
url(r'^wg-proceedings/$', LatestMeetingMaterialFeed()),
url(r'^rfc/(?P<year>\d{4})/?$', RfcFeed()),
url(r'^rfc/$', RfcFeed()),
url(r'^draft/?$', DraftFeed()),
]
4 changes: 2 additions & 2 deletions ietf/group/feeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2011-2020, All Rights Reserved
# Copyright The IETF Trust 2011-2024, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -44,7 +44,7 @@ def item_link(self, obj):
elif isinstance(obj, GroupEvent):
return obj.group.about_url()

def item_pubdate(self, obj):
def item_updateddate(self, obj):
return obj.time

def item_title(self, obj):
Expand Down
4 changes: 2 additions & 2 deletions ietf/iesg/feeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2020, All Rights Reserved
# Copyright The IETF Trust 2007-2024, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -27,7 +27,7 @@ def items(self):
def item_categories(self, doc):
return [ str(doc.latest_telechat_event.time.date()) ]

def item_pubdate(self, doc):
def item_updateddate(self, doc):
return doc.latest_telechat_event.time

def item_author_name(self, doc):
Expand Down
4 changes: 2 additions & 2 deletions ietf/ipr/feeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2023, All Rights Reserved
# Copyright The IETF Trust 2007-2024, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -28,7 +28,7 @@ def item_title(self, item):
def item_description(self, item):
return force_str(item.title)

def item_pubdate(self, item):
def item_updateddate(self, item):
return item.time

def item_author_name(self, item):
Expand Down
4 changes: 2 additions & 2 deletions ietf/liaisons/feeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2020, All Rights Reserved
# Copyright The IETF Trust 2007-2024, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -101,7 +101,7 @@ def item_description(self, item):
def item_link(self, item):
return urlreverse("ietf.liaisons.views.liaison_detail", kwargs={ "object_id": item.pk })

def item_pubdate(self, item):
def item_updateddate(self, item):
# this method needs to return a datetime instance, even
# though the database has only date, not time
return item.submitted
Expand Down
4 changes: 2 additions & 2 deletions ietf/meeting/feeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2007-2020, All Rights Reserved
# Copyright The IETF Trust 2007-2024, All Rights Reserved
# -*- coding: utf-8 -*-


Expand Down Expand Up @@ -45,7 +45,7 @@ def item_description(self, item):
def item_link(self, item):
return item['link']

def item_pubdate(self, item):
def item_updateddate(self, item):
return item['date']

def item_author_name(self, item):
Expand Down
8 changes: 4 additions & 4 deletions ietf/templates/community/atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title type="text">{{ title }}</title>
<subtitle type="text">{{ subtitle }}</subtitle>
<id>{{ id }}</id>
<updated>{{ updated|date:"Y-m-d\TH:i:sO" }}</updated>
<updated>{{ updated|date:"c" }}</updated>
<link rel="alternate" type="text/html" hreflang="en" href="https://{{ request.get_host }}/"/>
<link rel="self" type="application/atom+xml" href="https://{{ request.get_host }}{{ request.get_full_path }}"/>

Expand All @@ -17,11 +17,11 @@

<link href="{{ entry.doc.get_absolute_url }}"/>

<id>{{ entry.id }}</id>
<id>urn:uid:{{ entry.id }}</id>

<updated>{{ entry.time|date:"Y-m-d\TH:i:sO" }}</updated>
<updated>{{ entry.time|date:"c" }}</updated>

<published>{{ entry.time|date:"Y-m-d\TH:i:sO" }}</published>
<published>{{ entry.time|date:"c" }}</published>

<author>
<name>{{ entry.by }}</name>
Expand Down
3 changes: 2 additions & 1 deletion ietf/templates/doc/recent_drafts.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{# Copyright The IETF Trust 2015-2024, All Rights Reserved #}
{% load origin static %}
{% load cache %}
{% block pagehead %}
<link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
<link rel="alternate" type="application/atom+xml" href="/feed/draft/" title="Internet-Drafts">
{% endblock %}
{% block title %}Internet-Drafts submitted during the last {{ days|default:7 }} days{% endblock %}
{% block content %}
Expand Down
Loading