Skip to content

Commit

Permalink
fix: Add file ext to href for non-meeting slides (#7030)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-richards authored Feb 7, 2024
1 parent fa56223 commit 4c396e6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ietf/doc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c396e6

Please sign in to comment.