Skip to content

Commit

Permalink
Supply missing template for idnits2-rfcs-obsoleted. Add a view that p…
Browse files Browse the repository at this point in the history
…rovides the rfc-status blob used by idnits. Commit ready for merge.

 - Legacy-Id: 19263
  • Loading branch information
rjsparks committed Jul 28, 2021
1 parent 3283645 commit b179143
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ietf/doc/tests.py
Expand Up @@ -2388,4 +2388,11 @@ def test_obsoleted(self):
url = urlreverse('ietf.doc.views_doc.idnits2_rfcs_obsoleted')
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.assertEqual(r.content,b'1001 1003\n1005 1007\n')
self.assertEqual(r.content,b'1001 1003\n1005 1007\n')

def test_rfc_status(self):
url = urlreverse('ietf.doc.views_doc.idnits2_rfc_status')
r = self.client.get(url)
self.assertEqual(r.status_code,200)
blob = unicontent(r).replace('\n','')
self.assertEqual(blob[6312-1],'O')
1 change: 1 addition & 0 deletions ietf/doc/urls.py
Expand Up @@ -70,6 +70,7 @@
url(r'^html/%(name)s(?:-%(rev)s)?(\.txt|\.html)?/?$' % settings.URL_REGEXPS, views_doc.document_html),
url(r'^html/(?P<name>[Rr][Ff][Cc] [0-9]+?)(\.txt|\.html)?/?$', views_doc.document_html),
url(r'^idnits2-rfcs-obsoleted/?$', views_doc.idnits2_rfcs_obsoleted),
url(r'^idnits2-rfc-status/?$', views_doc.idnits2_rfc_status),

url(r'^all/?$', views_search.index_all_drafts),
url(r'^active/?$', views_search.index_active_drafts),
Expand Down
43 changes: 43 additions & 0 deletions ietf/doc/views_doc.py
Expand Up @@ -41,6 +41,7 @@
import os
import re
import markdown
import textwrap

from collections import defaultdict
from urllib.parse import quote
Expand Down Expand Up @@ -1730,3 +1731,45 @@ def idnits2_rfcs_obsoleted(request):

return render(request, 'doc/idnits2-rfcs-obsoleted.txt', context={'obsitems':sorted(obsdict.items())},content_type='text/plain;charset=utf-8')

@cache_page ( 60 * 60, cache="slowpages" )
def idnits2_rfc_status(request):

blob=['N']*10000

symbols={
'ps': 'P',
'inf': 'I',
'exp': 'E',
'ds': 'D',
'hist': 'H',
'std': 'S',
'bcp': 'B',
'unkn': 'U',
}

rfcs = Document.objects.filter(type_id='draft',states__slug='rfc',states__type='draft')
for rfc in rfcs:
offset = int(rfc.rfcnum)-1
blob[offset] = symbols[rfc.std_level_id]
if rfc.related_that('obs'):
blob[offset] = 'O'

# Workarounds for unusual states in the datatracker

# Document.get(docalias='rfc6312').rfcnum == 6342
# 6312 was published with the wrong rfc number in it
# weird workaround in the datatracker - there are two
# DocAliases starting with rfc - the canonical name code
# searches for the lexically highest alias starting with rfc
# which is getting lucky.
blob[6312 - 1] = 'O'

# RFC200 is an old RFC List by Number
blob[200 -1] = 'O'

# End Workarounds

blob = re.sub('N*$','',''.join(blob))

return HttpResponse(textwrap.fill(blob, width=64),content_type='text/plain;charset=utf-8')

2 changes: 2 additions & 0 deletions ietf/templates/doc/idnits2-rfcs-obsoleted.txt
@@ -0,0 +1,2 @@
{% load ietf_filters %}{% filter linebreaks_lf %}{% for k,l in obsitems %}{{k}} {{l|join:" "}}
{% endfor %}{% endfilter %}

0 comments on commit b179143

Please sign in to comment.