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
4 changed files with 10 additions and 16 deletions
Showing only changes of commit d88f0422ea - Show all commits

View File

@ -21,7 +21,7 @@
<div class="row ext-version-history pb-3"> <div class="row ext-version-history pb-3">
<div class="col"> <div class="col">
{% for version in extension.versions.all %} {% for version in object_list %}
{% if version.is_listed or is_maintainer %} {% if version.is_listed or is_maintainer %}
<details {% if forloop.counter == 1 %}open{% endif %} id="v{{ version.version|slugify }}"> <details {% if forloop.counter == 1 %}open{% endif %} id="v{{ version.version|slugify }}">
<summary> <summary>

View File

@ -30,17 +30,9 @@ class VersionsView(ExtensionQuerysetMixin, ListView):
paginate_by = 15 paginate_by = 15
def get_queryset(self): def get_queryset(self):
"""Allow logged in users to view unlisted versions in certain conditions.
* maintainers should be able to preview their yet unlisted versions;
* staff should be able to preview yet unlisted versions;
"""
self.extension_queryset = self.get_extension_queryset() self.extension_queryset = self.get_extension_queryset()
self.extension = get_object_or_404(self.extension_queryset, slug=self.kwargs['slug']) self.extension = get_object_or_404(self.extension_queryset, slug=self.kwargs['slug'])
queryset = self.extension.versions return self.extension.versions.prefetch_related('files', 'platforms', 'permissions')
if self.request.user.is_staff or self.extension.has_maintainer(self.request.user):
return queryset.all()
return queryset.listed
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)

View File

@ -227,6 +227,9 @@ class ExtensionDetailView(DetailView):
queryset = Extension.objects.listed.prefetch_related( queryset = Extension.objects.listed.prefetch_related(
'authors', 'authors',
'latest_version__files', 'latest_version__files',
'latest_version__files__validation',
'latest_version__permissions',
'latest_version__platforms',
'latest_version__tags', 'latest_version__tags',
'preview_set', 'preview_set',
'preview_set__file', 'preview_set__file',
@ -235,11 +238,6 @@ class ExtensionDetailView(DetailView):
'ratings__ratingreply__user', 'ratings__ratingreply__user',
'ratings__user', 'ratings__user',
'team', 'team',
'versions',
'versions__files',
'versions__files__validation',
'versions__permissions',
'versions__platforms',
).distinct() ).distinct()
context_object_name = 'extension' context_object_name = 'extension'
template_name = 'extensions/detail.html' template_name = 'extensions/detail.html'

View File

@ -77,9 +77,13 @@ class ExtensionsApprovalDetailView(DetailView):
def get_queryset(self): def get_queryset(self):
return self.model.objects.prefetch_related( return self.model.objects.prefetch_related(
'authors', 'authors',
'latest_version__files',
'latest_version__files__validation',
'latest_version__permissions',
'latest_version__platforms',
'latest_version__tags',
'preview_set', 'preview_set',
'preview_set__file', 'preview_set__file',
'versions',
).all() ).all()
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):