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
2 changed files with 6 additions and 6 deletions
Showing only changes of commit 3144d0c594 - Show all commits

View File

@ -679,7 +679,7 @@ class Version(CreatedModifiedMixin, TrackChangesMixin, models.Model):
@property
def can_upload_more_files(self):
return len(self.get_available_platforms()) > 0
return len(self.get_remaining_platforms()) > 0
def add_file(self, file: File):
self.files.add(file)
@ -706,7 +706,7 @@ class Version(CreatedModifiedMixin, TrackChangesMixin, models.Model):
for p in to_delete:
self.platforms.remove(Platform.objects.get(slug=p))
def get_available_platforms(self):
def get_remaining_platforms(self):
all_platforms = set(p.slug for p in Platform.objects.all())
for file in self.files.all():
platforms = file.platforms()

View File

@ -197,9 +197,9 @@ class ExtensionVersionManifestValidator:
# check for platforms
# TODO test coverage
available_platforms = version.get_available_platforms()
remaining_platforms = version.get_remaining_platforms()
if platforms := files.models.File.parse_platforms_from_manifest(manifest):
if diff := set(platforms) - available_platforms:
if diff := set(platforms) - remaining_platforms:
raise ValidationError(
{
'source': [f'{version} already has files for {", ".join(diff)}'],
@ -207,12 +207,12 @@ class ExtensionVersionManifestValidator:
code='invalid',
)
else:
if available_platforms:
if remaining_platforms:
raise ValidationError(
{
'source': [
f'File upload for {version} is allowed only for remaining platforms: '
f'{", ".join(available_platforms)}'
f'{", ".join(remaining_platforms)}'
],
},
code='invalid',