From 11ec3685c459fec9356b851a1d031490d5b70e42 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Fri, 7 Jul 2023 13:10:52 -0500 Subject: [PATCH] fix: repaired idnits2_state --- ietf/doc/tests.py | 10 ++++++---- ietf/doc/views_doc.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index fb80500fb4..fa9213da04 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -2595,10 +2595,10 @@ class Idnits2SupportTests(TestCase): settings_temp_path_overrides = TestCase.settings_temp_path_overrides + ['DERIVED_DIR'] def test_obsoleted(self): - rfc = WgRfcFactory(alias2__name='rfc1001') - WgRfcFactory(alias2__name='rfc1003',relations=[('obs',rfc)]) - rfc = WgRfcFactory(alias2__name='rfc1005') - WgRfcFactory(alias2__name='rfc1007',relations=[('obs',rfc)]) + rfc = WgRfcFactory(rfc_number=1001) + WgRfcFactory(rfc_number=1003,relations=[('obs',rfc)]) + rfc = WgRfcFactory(rfc_number=1005) + WgRfcFactory(rfc_number=1007,relations=[('obs',rfc)]) url = urlreverse('ietf.doc.views_doc.idnits2_rfcs_obsoleted') r = self.client.get(url) @@ -2623,6 +2623,8 @@ def test_rfc_status(self): def test_idnits2_state(self): rfc = WgRfcFactory() + draft = WgDraftFactory() + draft.relateddocument_set.create(relationship_id="became_rfc", target=rfc.docalias.first()) url = urlreverse('ietf.doc.views_doc.idnits2_state', kwargs=dict(name=rfc.canonical_name())) r = self.client.get(url) self.assertEqual(r.status_code, 200) diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index e299e61555..cc84057d19 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -2129,9 +2129,16 @@ def idnits2_rfc_status(request): def idnits2_state(request, name, rev=None): doc = get_object_or_404(Document, docalias__name=name) - if doc.type_id!='draft': + if doc.type_id not in ["draft", "rfc"]: raise Http404 - zero_revision = NewRevisionDocEvent.objects.filter(doc=doc,rev='00').first() + zero_revision = None + if doc.type_id == "rfc": + draft_alias = next(iter(doc.related_that('became_rfc')), None) + if draft_alias: + draft = draft_alias.document + zero_revision = NewRevisionDocEvent.objects.filter(doc=draft,rev='00').first() + else: + zero_revision = NewRevisionDocEvent.objects.filter(doc=doc,rev='00').first() if zero_revision: doc.created = zero_revision.time else: