Skip to content

Commit 7892e29

Browse files
committed
Port idtracker feeds to new schema, move them to doc/, clean up
idtracker/ - only templatetags/ietf_filters and proxy code is left - Legacy-Id: 5643
1 parent 564a97d commit 7892e29

12 files changed

Lines changed: 95 additions & 215 deletions

ietf/doc/feeds.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright The IETF Trust 2007, All Rights Reserved
2+
3+
import datetime, re
4+
5+
from django.conf import settings
6+
from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
7+
from django.utils.feedgenerator import Atom1Feed
8+
from django.core.urlresolvers import reverse as urlreverse
9+
from django.template.defaultfilters import truncatewords_html, date as datefilter, linebreaks
10+
from django.utils.html import strip_tags
11+
from django.utils.text import truncate_words
12+
13+
from ietf.doc.models import *
14+
from ietf.doc.utils import augment_events_with_revision
15+
from ietf.idtracker.templatetags.ietf_filters import format_textarea
16+
17+
class DocumentChanges(Feed):
18+
feed_type = Atom1Feed
19+
20+
def get_object(self, bits):
21+
if len(bits) != 1:
22+
raise Document.DoesNotExist
23+
24+
return Document.objects.get(docalias__name=bits[0])
25+
26+
def title(self, obj):
27+
return "Changes for %s" % obj.display_name()
28+
29+
def link(self, obj):
30+
if obj is None:
31+
raise FeedDoesNotExist
32+
if not hasattr(self, "cached_link"):
33+
self.cached_link = urlreverse("doc_history", kwargs=dict(name=obj.canonical_name()))
34+
return self.cached_link
35+
36+
def subtitle(self, obj):
37+
return "History of change entries for %s." % obj.display_name()
38+
39+
def items(self, obj):
40+
events = obj.docevent_set.all().order_by("-time","-id")
41+
augment_events_with_revision(obj, events)
42+
return events
43+
44+
def item_title(self, item):
45+
return u"[%s] %s [rev. %s]" % (item.by, truncate_words(strip_tags(item.desc), 15), item.rev)
46+
47+
def item_description(self, item):
48+
return truncatewords_html(format_textarea(item.desc), 20)
49+
50+
def item_pubdate(self, item):
51+
return item.time
52+
53+
def item_author_name(self, item):
54+
return unicode(item.by)
55+
56+
def item_link(self, item):
57+
return self.cached_link + "#history-%s" % item.pk
58+
59+
class InLastCall(Feed):
60+
title = "Documents in Last Call"
61+
subtitle = "Announcements for documents in last call."
62+
feed_type = Atom1Feed
63+
author_name = 'IESG Secretary'
64+
link = "/doc/iesg/last-call/"
65+
66+
def items(self):
67+
docs = list(Document.objects.filter(type="draft", states=State.objects.get(type="draft-iesg", slug="lc")))
68+
for d in docs:
69+
d.lc_event = d.latest_event(LastCallDocEvent, type="sent_last_call")
70+
71+
docs = [d for d in docs if d.lc_event]
72+
docs.sort(key=lambda d: d.lc_event.expires)
73+
74+
return docs
75+
76+
def item_title(self, item):
77+
return u"%s (%s - %s)" % (item.name,
78+
datefilter(item.lc_event.time, "F j"),
79+
datefilter(item.lc_event.expires, "F j, Y"))
80+
81+
def item_description(self, item):
82+
return linebreaks(item.lc_event.desc)
83+
84+
def item_pubdate(self, item):
85+
return item.lc_event.time
86+

ietf/idrfc/views_search.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@ def drafts_in_iesg_process(request, last_call_only=None):
403403

404404
grouped_docs.append((s, docs))
405405

406-
#drafts.sort(key=lambda d: (d.cur_state_id, d.status_date or datetime.date.min, d.b_sent_date or datetime.date.min))
407-
408406
return render_to_response('doc/drafts_in_iesg_process.html', {
409407
"grouped_docs": grouped_docs,
410408
"title": title,

ietf/idtracker/feeds.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

ietf/idtracker/tests.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22
#
3-
import doctest
3+
import doctest, unittest
4+
45
from ietf.idtracker.templatetags import ietf_filters
5-
import unittest
6-
from ietf.utils.test_utils import SimpleUrlTestCase, canonicalize_feed, canonicalize_sitemap
7-
import django.test
86

97
class TemplateTagTest(unittest.TestCase):
10-
def testTemplateTags(self):
11-
print " Testing ietf_filters"
12-
#doctest.testmod(ietf_filters,verbose=True)
13-
(failures, tests) = doctest.testmod(ietf_filters)
8+
def test_template_tags(self):
9+
failures, tests = doctest.testmod(ietf_filters)
1410
self.assertEqual(failures, 0)
15-
print "OK (ietf_filters)"
16-
17-
class IdTrackerUrlTestCase(SimpleUrlTestCase):
18-
def testUrls(self):
19-
self.doTestUrls(__file__)
20-
def doCanonicalize(self, url, content):
21-
if url.startswith("/feed/"):
22-
return canonicalize_feed(content)
23-
elif url.startswith("/sitemap"):
24-
return canonicalize_sitemap(content)
25-
else:
26-
return content
27-
28-
# class WGRoleTest(django.test.TestCase):
29-
# fixtures = ['wgtest']
30-
#
31-
# def setUp(self):
32-
# from ietf.idtracker.models import IETFWG
33-
# self.xmas = IETFWG.objects.get(group_acronym__acronym='xmas')
34-
# self.snow = IETFWG.objects.get(group_acronym__acronym='snow')
35-
#
36-
# def test_roles(self):
37-
# print " Testing WG roles"
38-
# self.assertEquals(self.xmas.wgchair_set.all()[0].role(), 'xmas WG Chair')
39-
# self.assertEquals(self.snow.wgchair_set.all()[0].role(), 'snow BOF Chair')
40-
# self.assertEquals(self.xmas.wgsecretary_set.all()[0].role(), 'xmas WG Secretary')
41-
# self.assertEquals(self.xmas.wgtechadvisor_set.all()[0].role(), 'xmas Technical Advisor')
42-
# print "OK"

ietf/idtracker/views.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

ietf/templates/doc/document_draft.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
| <a href="{% url ipr_search %}?option=document_search&amp;id={{ doc.name }}" rel="nofollow">IPR Disclosures</a>
228228
| <a href="http://www.fenron.net/~fenner/ietf/deps/index.cgi?dep={{ name }}" rel="nofollow">Dependencies to this document</a>
229229
| <a href="http://tools.ietf.org/idnits?url=http://tools.ietf.org/id/{{ doc.filename_with_rev }}" rel="nofollow" target="_blank">Check nits</a>
230-
| <a href="/feed/comments/{{ name }}/">History feed</a>
230+
| <a href="/feed/document-changes/{{ name }}/">History feed</a>
231231
| <a href="http://www.google.com/search?as_q={{ doc.name }}&as_sitesearch={{ search_archive }}" rel="nofollow" target="_blank">Search Mailing Lists</a>
232232
{% if user|has_role:"Area Director" %}
233233
| <a href="https://www.iesg.org/bin/c5i?mid=6&rid=77&target={{ doc.name }}" rel="nofollow" target="_blank">Search Mailing Lists (ARO)</a>

ietf/templates/doc/document_history.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
{% block pagehead %}
88
<link rel="stylesheet" type="text/css" href="/css/doc.css"></link>
9-
<link rel="alternate" type="application/atom+xml" href="/feed/comments/{{ doc.canonical_name }}/" />
9+
<link rel="alternate" type="application/atom+xml" href="/feed/document-changes/{{ doc.canonical_name }}/" />
1010
{% endblock %}
1111

1212
{% block content %}

ietf/templates/feeds/comments_description.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

ietf/templates/feeds/comments_title.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

ietf/templates/feeds/last-call_description.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)