Skip to content

Commit f0b8e49

Browse files
committed
Add two liaisons feeds:
* /feed/liaison/recent/ = last 15 liaisons * /feed/liaison/from/`from`/ = all liaisons from `from`, which is either an IETF wg acronym (all lowercase) or a FromBodies body_name (e.g., MFA%20Forum) - Legacy-Id: 903
1 parent e5f75ae commit f0b8e49

4 files changed

Lines changed: 80 additions & 0 deletions

File tree

ietf/liaisons/feeds.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright The IETF Trust 2007, All Rights Reserved
2+
3+
from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
4+
from django.utils.feedgenerator import Atom1Feed
5+
from ietf.liaisons.models import LiaisonDetail, FromBodies
6+
from ietf.idtracker.models import Acronym
7+
8+
# A slightly funny feed class, the 'object' is really
9+
# just a dict with some parameters that items() uses
10+
# to construct a queryset.
11+
class Liaisons(Feed):
12+
feed_type = Atom1Feed
13+
def get_object(self, bits):
14+
obj = {}
15+
if bits[0] == 'recent':
16+
if len(bits) != 1:
17+
raise FeedDoesNotExist
18+
obj['title'] = 'Recent Liaison Statements'
19+
obj['limit'] = 15
20+
return obj
21+
if bits[0] == 'from':
22+
if len(bits) != 2:
23+
raise FeedDoesNotExist
24+
obj['title'] = 'Liaison Statements from %s' % bits[1]
25+
try:
26+
acronym = Acronym.objects.get(acronym=bits[1])
27+
obj['filter'] = {'from_id': acronym.acronym_id}
28+
except Acronym.DoesNotExist:
29+
# would like to use from_body__body_name but relation
30+
# is broken due to database structure
31+
frmlist = [b['from_id'] for b in FromBodies.objects.filter(body_name=bits[1]).values('from_id')]
32+
if not frmlist:
33+
raise FeedDoesNotExist
34+
obj['filter'] = {'from_id__in': frmlist}
35+
return obj
36+
37+
def title(self, obj):
38+
return obj['title']
39+
40+
def link(self, obj):
41+
# no real equivalent for any objects
42+
return '/liaison/'
43+
44+
def description(self, obj):
45+
return self.title(obj)
46+
47+
def items(self, obj):
48+
# Start with the common queryset
49+
qs = LiaisonDetail.objects.all().order_by("-submitted_date")
50+
if obj.has_key('filter'):
51+
qs = qs.filter(**obj['filter'])
52+
if obj.has_key('limit'):
53+
qs = qs[:obj['limit']]
54+
return qs
55+
56+
def item_pubdate(self, item):
57+
return item.submitted_date
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{# Copyright The IETF Trust 2007, All Rights Reserved #}
2+
{% if obj.by_secretariat %}
3+
<h3>Attached Document(s)</h3>
4+
{% if obj.uploads_set.count %}
5+
<ul>
6+
{% for file in obj.uploads_set.all %}
7+
<li><a href="https://datatracker.ietf.org/documents/LIAISON/file{{ file.file_id }}{{ file.file_extension }}">{{ file.file_title }}</a><br>
8+
{% endfor %}
9+
</ul>
10+
{% else %}
11+
NONE
12+
{% endif %}
13+
{% else %}
14+
{{ obj.body|truncatewords:"30"|wordwrap:"71"|escape|linebreaksbr }}
15+
{% endif %}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{# Copyright The IETF Trust 2007, All Rights Reserved #}
2+
{% if obj.by_secretariat %}
3+
Liaison statement submitted by email from {{ obj.from_body|escape }} on {{ obj.submitted_date }}
4+
{% else %}
5+
{{ obj.title|escape }}
6+
{% endif %}

ietf/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ietf.iesg.feeds import IESGMinutes
66
from ietf.idtracker.feeds import DocumentComments, InLastCall
77
from ietf.ipr.feeds import LatestIprDisclosures
8+
from ietf.liaisons.feeds import Liaisons
89

910
from ietf.idtracker.sitemaps import IDTrackerMap, DraftMap
1011
from ietf.liaisons.sitemaps import LiaisonMap
@@ -19,6 +20,7 @@
1920
'last-call': InLastCall,
2021
'comments': DocumentComments,
2122
'ipr': LatestIprDisclosures,
23+
'liaison': Liaisons,
2224
}
2325

2426
sitemaps = {

0 commit comments

Comments
 (0)