5757import debug # pyflakes:ignore
5858
5959from ietf .doc .fields import SearchableDocumentsField
60- from ietf .doc .models import Document , State , DocEvent , NewRevisionDocEvent , DocHistory
60+ from ietf .doc .models import Document , State , DocEvent , NewRevisionDocEvent
6161from ietf .doc .storage_utils import (
6262 remove_from_storage ,
6363 retrieve_bytes ,
9898 organize_proceedings_sessions ,
9999 resolve_uploaded_material ,
100100 sort_accept_tuple ,
101- resolve_one_material ,
102101)
103102from ietf .meeting .utils import add_event_info_to_session_qs
104103from ietf .meeting .utils import session_time_for_sorting
@@ -262,7 +261,7 @@ def current_materials(request):
262261 raise Http404 ('No such meeting' )
263262
264263
265- def _get_materials_doc (name , meeting = None ) -> tuple [ Document | DocHistory , str | None ] :
264+ def _get_materials_doc (name , meeting = None ):
266265 """Get meeting materials document named by name
267266
268267 Raises Document.DoesNotExist if a match cannot be found. If meeting is None,
@@ -275,23 +274,15 @@ def _matches_meeting(doc, meeting=None):
275274 return doc .get_related_meeting () == meeting
276275
277276 # try an exact match first
278- doc : Document | DocHistory | None = Document .objects .filter (name = name ).first ()
277+ doc = Document .objects .filter (name = name ).first ()
279278 if doc is not None and _matches_meeting (doc , meeting ):
280279 return doc , None
281280
282281 # try parsing a rev number
283282 if "-" in name :
284283 docname , rev = name .rsplit ("-" , 1 )
285284 if len (rev ) == 2 and rev .isdigit ():
286- try :
287- # may raise Document.DoesNotExist
288- doc = Document .objects .get (name = docname , rev = rev )
289- except Document .DoesNotExist :
290- doc = DocHistory .objects .filter (
291- name = docname , rev = rev ,
292- ).order_by ("-time" ).first ()
293- if doc is None :
294- raise
285+ doc = Document .objects .get (name = docname ) # may raise Document.DoesNotExist
295286 if (
296287 _matches_meeting (doc , meeting )
297288 and rev in doc .revisions_by_newrevisionevent ()
@@ -371,62 +362,6 @@ def materials_document(request, document, num=None, ext=None):
371362 return HttpResponseRedirect (redirect_to = doc .get_href (meeting = meeting ))
372363
373364
374- @requires_api_token
375- def api_resolve_materials_name (request , document , num = None , ext = None ):
376- """Resolve materials name into document to a blob spec
377-
378- Returns the bucket/name of a blob in the blob store that corresponds to the named
379- document. Handles resolution of revision if it is not specified and determines the
380- best extension if one is not provided. Response is JSON.
381-
382- As of 2025-10-10 we do not have blobs for all materials documents or for every
383- format of every document. This API still returns the bucket/name as if the blob
384- exists. Another API will allow the caller to obtain the file contents using that
385- name if it cannot be retrieved from the blob store.
386- """
387-
388- def _error_response (status : int , detail : str ):
389- return JsonResponse (
390- {
391- "status" : status ,
392- "title" : "Error" ,
393- "detail" : detail ,
394- },
395- status = status ,
396- )
397-
398- def _response (bucket : str , name : str ):
399- return JsonResponse (
400- {
401- "bucket" : bucket ,
402- "name" : name ,
403- }
404- )
405-
406- try :
407- meeting = get_meeting (num , type_in = ["ietf" , "interim" ])
408- except Http404 as err404 :
409- return _error_response (
410- HTTP_404_NOT_FOUND , str (err404 )
411- )
412-
413- num = meeting .number
414- try :
415- doc , rev = _get_materials_doc (name = document , meeting = meeting )
416- except Document .DoesNotExist :
417- return _error_response (
418- HTTP_404_NOT_FOUND , f"No such document for meeting { num } "
419- )
420-
421- resolved = resolve_one_material (doc , rev , ext )
422- if resolved is not None :
423- return _response (bucket = resolved .bucket , name = resolved .name )
424-
425- return _error_response (
426- HTTP_404_NOT_FOUND , f"No suitable file for { document } for meeting { num } "
427- )
428-
429-
430365@requires_api_token ("ietf.meeting.views.api_resolve_materials_name" )
431366def api_resolve_materials_name_cached (request , document , num = None , ext = None ):
432367 """Resolve materials name into document to a blob spec
0 commit comments