|
35 | 35 | from django.http import HttpResponse, HttpResponsePermanentRedirect |
36 | 36 | from django.template import loader |
37 | 37 | from django.shortcuts import get_object_or_404 |
38 | | -from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, Rfc, IDInternal |
| 38 | +from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, IDInternal |
39 | 39 |
|
40 | 40 | def all_id_txt(): |
41 | 41 | all_ids = InternetDraft.objects.order_by('filename') |
@@ -73,54 +73,6 @@ def test_id_index_txt(request): |
73 | 73 | def test_id_abstracts_txt(request): |
74 | 74 | return HttpResponse(id_abstracts_txt(), mimetype='text/plain') |
75 | 75 |
|
76 | | -def related_docs(startdoc): |
77 | | - related = [] |
78 | | - processed = [] |
79 | | - |
80 | | - def handle(otherdoc,status,doc,skip=(0,0,0)): |
81 | | - new = (otherdoc, status, doc) |
82 | | - if otherdoc in processed: |
83 | | - return |
84 | | - related.append(new) |
85 | | - process(otherdoc,skip) |
86 | | - |
87 | | - def process(doc, skip=(0,0,0)): |
88 | | - processed.append(doc) |
89 | | - if type(doc) == InternetDraft: |
90 | | - if doc.replaced_by_id != 0 and not(skip[0]): |
91 | | - handle(doc.replaced_by, "that replaces", doc, (0,1,0)) |
92 | | - if not(skip[1]): |
93 | | - for replaces in doc.replaces_set.all(): |
94 | | - handle(replaces, "that was replaced by", doc, (1,0,0)) |
95 | | - if doc.rfc_number != 0 and not(skip[0]): |
96 | | - # should rfc be an FK in the model? |
97 | | - try: |
98 | | - handle(Rfc.objects.get(rfc_number=doc.rfc_number), "which came from", doc, (1,0,0)) |
99 | | - # In practice, there are missing rows in the RFC table. |
100 | | - except Rfc.DoesNotExist: |
101 | | - pass |
102 | | - if type(doc) == Rfc: |
103 | | - if not(skip[0]): |
104 | | - try: |
105 | | - draft = InternetDraft.objects.get(rfc_number=doc.rfc_number) |
106 | | - handle(draft, "that was published as", doc, (0,0,1)) |
107 | | - except InternetDraft.DoesNotExist: |
108 | | - pass |
109 | | - # The table has multiple documents published as the same RFC. |
110 | | - # This raises an AssertionError because using get |
111 | | - # presumes there is exactly one. |
112 | | - except AssertionError: |
113 | | - pass |
114 | | - if not(skip[1]): |
115 | | - for obsoleted_by in doc.updated_or_obsoleted_by.all(): |
116 | | - handle(obsoleted_by.rfc, "that %s" % obsoleted_by.action.lower(), doc) |
117 | | - if not(skip[2]): |
118 | | - for obsoletes in doc.updates_or_obsoletes.all(): |
119 | | - handle(obsoletes.rfc_acted_on, "that was %s by" % obsoletes.action.lower().replace("tes", "ted"), doc) |
120 | | - |
121 | | - process(startdoc, (0,0,0)) |
122 | | - return related |
123 | | - |
124 | 76 | def redirect_id(request, object_id): |
125 | 77 | '''Redirect from historical document ID to preferred filename url.''' |
126 | 78 | doc = get_object_or_404(InternetDraft, id_document_tag=object_id) |
|
0 commit comments