Addresses issue #628, using reverse() and the newly created helper function reverse_lazy() (found in ietf/utils/lazy.py) to DRY out the code a bit by decoupling the urls from being hardcoded. With this commit idrfc, and ipr modules have been modified to take advantage of the reverse() and reverse_lazy() functions. - Legacy-Id: 2956 Note: SVN reference [2948] has been migrated to Git commit 9399a2e0e8bbfe5c5a16781fd784776cfa31fbac
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# Copyright The IETF Trust 2007, All Rights Reserved
|
|
|
|
from django.contrib.syndication.feeds import Feed
|
|
from django.utils.feedgenerator import Atom1Feed
|
|
from ietf.ipr.models import IprDetail
|
|
from ietf.utils.lazy import reverse_lazy
|
|
from datetime import datetime, time
|
|
|
|
class LatestIprDisclosures(Feed):
|
|
feed_type = Atom1Feed
|
|
title = "IPR Disclosures to the IETF"
|
|
link = reverse_lazy('ipr_showlist')
|
|
description = "Updates on new IPR Disclosures made to the IETF."
|
|
language = "en"
|
|
feed_url = "/feed/ipr/"
|
|
|
|
def items(self):
|
|
return IprDetail.objects.filter(status__in=[1,3]).order_by('-submitted_date')[:30]
|
|
|
|
def item_pubdate(self, item):
|
|
# this method needs to return a datetime instance, even
|
|
# though the database has only date, not time
|
|
return datetime.combine(item.submitted_date, time(0,0,0))
|
|
def item_author_name(self, item):
|
|
s = item.get_submitter()
|
|
if s:
|
|
if isinstance(s.name, unicode):
|
|
# for django.VERSION[0] > 0
|
|
return s.name
|
|
else:
|
|
# for django.VERSION[0] == 0
|
|
return unicode(s.name, encoding='utf-8', errors='replace')
|
|
return None
|
|
def item_author_email(self, item):
|
|
s = item.get_submitter()
|
|
if s:
|
|
return s.email
|
|
return None
|