From 01dec633ea88e940d68cf4b441838654daabaf7a Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 7 Feb 2024 13:49:23 -0400 Subject: [PATCH] fix: Add file ext to href for non-meeting slides --- ietf/doc/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ietf/doc/models.py b/ietf/doc/models.py index 536e3e3493..af4843fc41 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -280,6 +280,19 @@ def _get_ref(self, meeting=None, meeting_doc_refs=settings.MEETING_DOC_HREFS): info = dict(doc=self) href = format.format(**info) + + # For slides that are not meeting-related, we need to know the file extension. + # Assume we have access to the same files as settings.DOC_HREFS["slides"] and + # see what extension is available + if self.type_id == "slides" and not self.meeting_related() and not href.endswith("/"): + filepath = Path(self.get_file_path()) / self.get_base_name() # start with this + if not filepath.exists(): + # Look for other extensions - grab the first one, sorted for stability + for existing in sorted(filepath.parent.glob(f"{filepath.stem}.*")): + filepath = filepath.with_suffix(existing.suffix) + break + href += filepath.suffix # tack on the extension + if href.startswith('/'): href = settings.IDTRACKER_BASE_URL + href self._cached_href = href