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
This commit is contained in:
parent
e5f75ae2b1
commit
f0b8e49ed5
57
ietf/liaisons/feeds.py
Normal file
57
ietf/liaisons/feeds.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
|
||||
from django.utils.feedgenerator import Atom1Feed
|
||||
from ietf.liaisons.models import LiaisonDetail, FromBodies
|
||||
from ietf.idtracker.models import Acronym
|
||||
|
||||
# A slightly funny feed class, the 'object' is really
|
||||
# just a dict with some parameters that items() uses
|
||||
# to construct a queryset.
|
||||
class Liaisons(Feed):
|
||||
feed_type = Atom1Feed
|
||||
def get_object(self, bits):
|
||||
obj = {}
|
||||
if bits[0] == 'recent':
|
||||
if len(bits) != 1:
|
||||
raise FeedDoesNotExist
|
||||
obj['title'] = 'Recent Liaison Statements'
|
||||
obj['limit'] = 15
|
||||
return obj
|
||||
if bits[0] == 'from':
|
||||
if len(bits) != 2:
|
||||
raise FeedDoesNotExist
|
||||
obj['title'] = 'Liaison Statements from %s' % bits[1]
|
||||
try:
|
||||
acronym = Acronym.objects.get(acronym=bits[1])
|
||||
obj['filter'] = {'from_id': acronym.acronym_id}
|
||||
except Acronym.DoesNotExist:
|
||||
# would like to use from_body__body_name but relation
|
||||
# is broken due to database structure
|
||||
frmlist = [b['from_id'] for b in FromBodies.objects.filter(body_name=bits[1]).values('from_id')]
|
||||
if not frmlist:
|
||||
raise FeedDoesNotExist
|
||||
obj['filter'] = {'from_id__in': frmlist}
|
||||
return obj
|
||||
|
||||
def title(self, obj):
|
||||
return obj['title']
|
||||
|
||||
def link(self, obj):
|
||||
# no real equivalent for any objects
|
||||
return '/liaison/'
|
||||
|
||||
def description(self, obj):
|
||||
return self.title(obj)
|
||||
|
||||
def items(self, obj):
|
||||
# Start with the common queryset
|
||||
qs = LiaisonDetail.objects.all().order_by("-submitted_date")
|
||||
if obj.has_key('filter'):
|
||||
qs = qs.filter(**obj['filter'])
|
||||
if obj.has_key('limit'):
|
||||
qs = qs[:obj['limit']]
|
||||
return qs
|
||||
|
||||
def item_pubdate(self, item):
|
||||
return item.submitted_date
|
15
ietf/templates/feeds/liaison_description.html
Normal file
15
ietf/templates/feeds/liaison_description.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
{# Copyright The IETF Trust 2007, All Rights Reserved #}
|
||||
{% if obj.by_secretariat %}
|
||||
<h3>Attached Document(s)</h3>
|
||||
{% if obj.uploads_set.count %}
|
||||
<ul>
|
||||
{% for file in obj.uploads_set.all %}
|
||||
<li><a href="https://datatracker.ietf.org/documents/LIAISON/file{{ file.file_id }}{{ file.file_extension }}">{{ file.file_title }}</a><br>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
NONE
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ obj.body|truncatewords:"30"|wordwrap:"71"|escape|linebreaksbr }}
|
||||
{% endif %}
|
6
ietf/templates/feeds/liaison_title.html
Normal file
6
ietf/templates/feeds/liaison_title.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{# Copyright The IETF Trust 2007, All Rights Reserved #}
|
||||
{% if obj.by_secretariat %}
|
||||
Liaison statement submitted by email from {{ obj.from_body|escape }} on {{ obj.submitted_date }}
|
||||
{% else %}
|
||||
{{ obj.title|escape }}
|
||||
{% endif %}
|
|
@ -5,6 +5,7 @@ from django.conf.urls.defaults import patterns, include, handler404, handler500
|
|||
from ietf.iesg.feeds import IESGMinutes
|
||||
from ietf.idtracker.feeds import DocumentComments, InLastCall
|
||||
from ietf.ipr.feeds import LatestIprDisclosures
|
||||
from ietf.liaisons.feeds import Liaisons
|
||||
|
||||
from ietf.idtracker.sitemaps import IDTrackerMap, DraftMap
|
||||
from ietf.liaisons.sitemaps import LiaisonMap
|
||||
|
@ -19,6 +20,7 @@ feeds = {
|
|||
'last-call': InLastCall,
|
||||
'comments': DocumentComments,
|
||||
'ipr': LatestIprDisclosures,
|
||||
'liaison': Liaisons,
|
||||
}
|
||||
|
||||
sitemaps = {
|
||||
|
|
Loading…
Reference in a new issue