Multi-platform: support multiple files per version #201
@ -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
|
||||
Oleg-Komarov marked this conversation as resolved
Outdated
|
||||
|
||||
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):
|
||||
Oleg-Komarov marked this conversation as resolved
Outdated
Anna Sirota
commented
or in the sense that these are the platforms which don't yet have files uploaded for them, if any platform-specific file were uploaded or `s/get_available_platforms/get_remaining_platforms/`
in the sense that these are the platforms which don't yet have files uploaded for them, if any platform-specific file were uploaded
|
||||
all_platforms = set(p.slug for p in Platform.objects.all())
|
||||
for file in self.files.all():
|
||||
platforms = file.platforms()
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user
s/get_available_platforms/get_missing_platforms/
?