Multi-platform: support multiple files per version #201
@ -21,7 +21,7 @@
|
||||
|
||||
<div class="row ext-version-history pb-3">
|
||||
<div class="col">
|
||||
{% for version in extension.versions.all %}
|
||||
{% for version in object_list %}
|
||||
{% if version.is_listed or is_maintainer %}
|
||||
<details {% if forloop.counter == 1 %}open{% endif %} id="v{{ version.version|slugify }}">
|
||||
<summary>
|
||||
|
@ -30,17 +30,9 @@ class VersionsView(ExtensionQuerysetMixin, ListView):
|
||||
paginate_by = 15
|
||||
|
||||
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 = get_object_or_404(self.extension_queryset, slug=self.kwargs['slug'])
|
||||
queryset = self.extension.versions
|
||||
if self.request.user.is_staff or self.extension.has_maintainer(self.request.user):
|
||||
return queryset.all()
|
||||
return queryset.listed
|
||||
return self.extension.versions.prefetch_related('files', 'platforms', 'permissions')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
@ -227,6 +227,9 @@ class ExtensionDetailView(DetailView):
|
||||
queryset = Extension.objects.listed.prefetch_related(
|
||||
'authors',
|
||||
'latest_version__files',
|
||||
'latest_version__files__validation',
|
||||
'latest_version__permissions',
|
||||
'latest_version__platforms',
|
||||
'latest_version__tags',
|
||||
'preview_set',
|
||||
'preview_set__file',
|
||||
@ -235,11 +238,6 @@ class ExtensionDetailView(DetailView):
|
||||
'ratings__ratingreply__user',
|
||||
'ratings__user',
|
||||
'team',
|
||||
'versions',
|
||||
'versions__files',
|
||||
'versions__files__validation',
|
||||
'versions__permissions',
|
||||
'versions__platforms',
|
||||
).distinct()
|
||||
context_object_name = 'extension'
|
||||
template_name = 'extensions/detail.html'
|
||||
|
@ -77,9 +77,13 @@ class ExtensionsApprovalDetailView(DetailView):
|
||||
def get_queryset(self):
|
||||
return self.model.objects.prefetch_related(
|
||||
'authors',
|
||||
'latest_version__files',
|
||||
'latest_version__files__validation',
|
||||
'latest_version__permissions',
|
||||
'latest_version__platforms',
|
||||
'latest_version__tags',
|
||||
'preview_set',
|
||||
'preview_set__file',
|
||||
'versions',
|
||||
).all()
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user