Multi-platform: support multiple files per version #201

Merged
Oleg-Komarov merged 43 commits from multi-os into main 2024-07-09 16:27:46 +02:00
Showing only changes of commit 8b376825c8 - Show all commits

View File

@ -757,14 +757,13 @@ class Version(CreatedModifiedMixin, TrackChangesMixin, models.Model):
def _get_download_name(self, platform=None) -> str:
"""Return a file name for downloads."""
replace_char = f'{self}'.replace('.', '-')
parts = [self.extension.type_slug_singular, self.extension.slug, f'v{self.version}']
Oleg-Komarov marked this conversation as resolved Outdated

The filename below
filename = f'{self.extension.type_slug_singular}-{self.extension.slug}-v{self.version}.zip'

looks like a better name: doesn't rely on self.__str__.

It also looks like these file names should be the same in both places.

The `filename` below `filename = f'{self.extension.type_slug_singular}-{self.extension.slug}-v{self.version}.zip'` looks like a better name: doesn't rely on `self.__str__`. It also looks like these file names should be the same in both places.
if platform:
return f'{utils.slugify(replace_char)}.{platform}.zip'
else:
return f'{utils.slugify(replace_char)}.zip'
parts.append(platform)
Oleg-Komarov marked this conversation as resolved Outdated

to avoid making platform into file ext, maybe -?

to avoid making platform into file ext, maybe `-`?
return f'{"-".join(parts)}.zip'
def get_download_url(self, platform=None, append_repository_and_compatibility=True) -> str:
filename = f'{self.extension.type_slug_singular}-{self.extension.slug}-v{self.version}.zip'
filename = self._get_download_name(platform=platform)
if platform:
download_url = reverse(
'extensions:version-platform-download',