Skip to content

Commit 3283645

Browse files
committed
Provide replacement for idnits2's use of tools.ietf.org for a representation of obsoleted RFCs. Commit ready for merge.
- Legacy-Id: 19262
1 parent a294807 commit 3283645

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

ietf/doc/tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,3 +2377,15 @@ def test_markdown_and_text(self):
23772377
self.assertEqual(r.status_code,200)
23782378
q = PyQuery(r.content)
23792379
self.assertEqual(q('#materials-content .panel-body a').attr['href'],'https://unusual.example')
2380+
2381+
class Idnits2SupportTests(TestCase):
2382+
2383+
def test_obsoleted(self):
2384+
for i in range(2):
2385+
rfc = WgRfcFactory()
2386+
WgRfcFactory(relations=[('obs',rfc)])
2387+
2388+
url = urlreverse('ietf.doc.views_doc.idnits2_rfcs_obsoleted')
2389+
r = self.client.get(url)
2390+
self.assertEqual(r.status_code, 200)
2391+
self.assertEqual(r.content,b'1001 1003\n1005 1007\n')

ietf/doc/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
url(r'^html/(?P<name>std[0-9]+?)(\.txt|\.html)?/?$', RedirectView.as_view(url=settings.RFC_EDITOR_INFO_BASE_URL+"%(name)s", permanent=False)),
7070
url(r'^html/%(name)s(?:-%(rev)s)?(\.txt|\.html)?/?$' % settings.URL_REGEXPS, views_doc.document_html),
7171
url(r'^html/(?P<name>[Rr][Ff][Cc] [0-9]+?)(\.txt|\.html)?/?$', views_doc.document_html),
72+
url(r'^idnits2-rfcs-obsoleted/?$', views_doc.idnits2_rfcs_obsoleted),
7273

7374
url(r'^all/?$', views_search.index_all_drafts),
7475
url(r'^active/?$', views_search.index_active_drafts),

ietf/doc/views_doc.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import re
4343
import markdown
4444

45+
from collections import defaultdict
4546
from urllib.parse import quote
4647

4748
from django.http import HttpResponse, Http404
@@ -50,12 +51,14 @@
5051
from django.urls import reverse as urlreverse
5152
from django.conf import settings
5253
from django import forms
54+
from django.views.decorators.cache import cache_page
55+
5356

5457
import debug # pyflakes:ignore
5558

5659
from ietf.doc.models import ( Document, DocAlias, DocHistory, DocEvent, BallotDocEvent, BallotType,
5760
ConsensusDocEvent, NewRevisionDocEvent, TelechatDocEvent, WriteupDocEvent, IanaExpertDocEvent,
58-
IESG_BALLOT_ACTIVE_STATES, STATUSCHANGE_RELATIONS, DocumentActionHolder, DocumentAuthor)
61+
IESG_BALLOT_ACTIVE_STATES, STATUSCHANGE_RELATIONS, DocumentActionHolder, DocumentAuthor, RelatedDocument)
5962
from ietf.doc.utils import (add_links_in_new_revision_events, augment_events_with_revision,
6063
can_adopt_draft, can_unadopt_draft, get_chartering_type, get_tags_for_stream_id,
6164
needed_ballot_positions, nice_consensus, prettify_std_name, update_telechat, has_same_ballot,
@@ -1714,3 +1717,16 @@ def all_presentations(request, name):
17141717
'in_progress': in_progress,
17151718
'past' : past+recent,
17161719
})
1720+
1721+
@cache_page ( 60 * 60, cache="slowpages" )
1722+
def idnits2_rfcs_obsoleted(request):
1723+
1724+
obsdict = defaultdict(list)
1725+
for r in RelatedDocument.objects.filter(relationship_id='obs'):
1726+
obsdict[int(r.target.document.rfc_number())].append(int(r.source.rfc_number()))
1727+
1728+
for k in obsdict:
1729+
obsdict[k] = sorted(obsdict[k])
1730+
1731+
return render(request, 'doc/idnits2-rfcs-obsoleted.txt', context={'obsitems':sorted(obsdict.items())},content_type='text/plain;charset=utf-8')
1732+

0 commit comments

Comments
 (0)