fix: repaired idnits2_state
This commit is contained in:
parent
e6a1a17973
commit
11ec3685c4
|
@ -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 @@ class Idnits2SupportTests(TestCase):
|
|||
|
||||
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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue