5757import debug # pyflakes:ignore
5858
5959from ietf .doc .fields import SearchableDocumentsField
60- from ietf .doc .models import Document , State , DocEvent , NewRevisionDocEvent , StoredObject
60+ from ietf .doc .models import Document , State , DocEvent , NewRevisionDocEvent , \
61+ StoredObject , DocHistory
6162from ietf .doc .storage_utils import (
6263 remove_from_storage ,
6364 retrieve_bytes ,
@@ -258,7 +259,7 @@ def current_materials(request):
258259 raise Http404 ('No such meeting' )
259260
260261
261- def _get_materials_doc (name , meeting = None ):
262+ def _get_materials_doc (name , meeting = None ) -> tuple [ Document | DocHistory , str | None ] :
262263 """Get meeting materials document named by name
263264
264265 Raises Document.DoesNotExist if a match cannot be found. If meeting is None,
@@ -279,7 +280,11 @@ def _matches_meeting(doc, meeting=None):
279280 if "-" in name :
280281 docname , rev = name .rsplit ("-" , 1 )
281282 if len (rev ) == 2 and rev .isdigit ():
282- doc = Document .objects .get (name = docname ) # may raise Document.DoesNotExist
283+ try :
284+ doc = DocHistory .objects .get (name = docname , rev = rev )
285+ except DocHistory .DoesNotExist :
286+ # may raise Document.DoesNotExist
287+ doc = Document .objects .get (name = docname , rev = rev )
283288 if (
284289 _matches_meeting (doc , meeting )
285290 and rev in doc .revisions_by_newrevisionevent ()
0 commit comments