Skip to content

Commit 0293382

Browse files
committed
Tweak ordering to be like the cgi version.
Remove debugging and leftover bits from related_docs function. Handle unexpected exceptions in related_docs related to schema oddities described in adamlaska#98: * There might not be a row in the RFC table for a given rfc_number of an I-D * There might be multiple documents published as the same RFC Don't skip anything when recursing from our equivalents of get_rfcs_obsoleted and get_rfcs_obsoleted_by. - Legacy-Id: 521
1 parent c85c6a5 commit 0293382

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

ietf/idindex/views.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def wglist(request, wg=None):
1818
)
1919
else:
2020
queryset = IETFWG.objects.filter(group_acronym__acronym__istartswith=wg)
21-
queryset = queryset.filter(group_type__type='WG').select_related().order_by('g_status.status', 'acronym.acronym')
21+
queryset = queryset.filter(group_type__type='WG').select_related().order_by('status_id', 'acronym.acronym')
2222
return object_list(request, queryset=queryset, template_name='idindex/wglist.html', allow_empty=True, extra_context=base_extra)
2323

2424
def wgdocs(request, **kwargs):
@@ -57,7 +57,7 @@ def otherdocs(request, cat=None):
5757
orl([Q(filename__istartswith="draft-%s-" % p)|
5858
Q(filename__istartswith="draft-ietf-%s-" % p)
5959
for p in org.get('prefixes', [ org['key'] ])]))
60-
queryset = queryset.order_by('filename')
60+
queryset = queryset.order_by('status_id','filename')
6161
extra = base_extra
6262
extra['category'] = cat
6363
return object_list(request, queryset=queryset, template_name='idindex/otherdocs.html', allow_empty=True, extra_context=extra)
@@ -127,7 +127,7 @@ def search(request):
127127
except KeyError:
128128
pass # either no other_group arg or no orgs_dict entry
129129
matches = InternetDraft.objects.all().filter(*q_objs)
130-
matches = matches.order_by('filename')
130+
matches = matches.order_by('status_id', 'filename')
131131
searched = True
132132
else:
133133
matches = None
@@ -167,18 +167,11 @@ def related_docs(startdoc):
167167
def handle(otherdoc,status,doc,skip=(0,0,0)):
168168
new = (otherdoc, status, doc)
169169
if otherdoc in processed:
170-
#print "skipping (%s,%s,%s) because otherdoc has been processed" % (new)
171170
return
172-
#if new not in related:
173-
if True: #otherdoc not in processed:
174-
related.append(new)
175-
if otherdoc not in processed: # now simply redundant
176-
process(otherdoc,skip)
171+
related.append(new)
172+
process(otherdoc,skip)
177173

178174
def process(doc, skip=(0,0,0)):
179-
#XXX
180-
skip = (0,0,0)
181-
#print "doc = %s skip = %s" % (doc,skip)
182175
processed.append(doc)
183176
if type(doc) == InternetDraft:
184177
if doc.replaced_by_id != 0 and not(skip[0]):
@@ -188,21 +181,29 @@ def process(doc, skip=(0,0,0)):
188181
handle(replaces, "that was replaced by", doc, (1,0,0))
189182
if doc.rfc_number != 0 and not(skip[0]):
190183
# should rfc be an FK in the model?
191-
handle(Rfc.objects.get(rfc_number=doc.rfc_number), "which came from", doc, (1,0,0))
184+
try:
185+
handle(Rfc.objects.get(rfc_number=doc.rfc_number), "which came from", doc, (1,0,0))
186+
# In practice, there are missing rows in the RFC table.
187+
except Rfc.DoesNotExist:
188+
pass
192189
if type(doc) == Rfc:
193190
if not(skip[0]):
194191
try:
195192
draft = InternetDraft.objects.get(rfc_number=doc.rfc_number)
196-
#handle(doc, "which came from", draft, backwards=True)
197193
handle(draft, "that was published as", doc, (0,0,1))
198194
except InternetDraft.DoesNotExist:
199195
pass
196+
# The table has multiple documents published as the same RFC.
197+
# This raises an AssertionError because using get
198+
# presumes there is exactly one.
199+
except AssertionError:
200+
pass
200201
if not(skip[1]):
201202
for obsoleted_by in doc.updated_or_obsoleted_by.all():
202-
handle(obsoleted_by.rfc, "that %s" % obsoleted_by.action.lower(), doc, (0,0,1))
203+
handle(obsoleted_by.rfc, "that %s" % obsoleted_by.action.lower(), doc)
203204
if not(skip[2]):
204205
for obsoletes in doc.updates_or_obsoletes.all():
205-
handle(obsoletes.rfc_acted_on, "that was %s by" % obsoletes.action.lower().replace("tes", "ted"), doc, (0,1,0))
206+
handle(obsoletes.rfc_acted_on, "that was %s by" % obsoletes.action.lower().replace("tes", "ted"), doc)
206207

207208
process(startdoc, (0,0,0))
208209
return related

0 commit comments

Comments
 (0)