Make it possible to fully delete unlisted/unrated extensions #81
@ -361,8 +361,9 @@ class DraftExtensionView(
|
|||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
"""Return initial values for the version, based on the file."""
|
"""Return initial values for the version, based on the file."""
|
||||||
initial = super().get_initial()
|
initial = super().get_initial()
|
||||||
initial['file'] = self.version.file
|
if self.version:
|
||||||
initial.update(**self.version.file.parsed_version_fields)
|
initial['file'] = self.version.file
|
||||||
|
initial.update(**self.version.file.parsed_version_fields)
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
def get_context_data(self, form=None, extension_form=None, add_preview_formset=None, **kwargs):
|
def get_context_data(self, form=None, extension_form=None, add_preview_formset=None, **kwargs):
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.core.exceptions import BadRequest
|
|
||||||
|
|
||||||
from extensions.models import Extension
|
from extensions.models import Extension
|
||||||
from files.models import File
|
from files.models import File
|
||||||
@ -60,9 +59,6 @@ class DraftVersionMixin:
|
|||||||
|
|
||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
self.version = self.extension.versions.first()
|
self.version = self.extension.versions.first()
|
||||||
if self.version is None:
|
|
||||||
error_message = f'Extension "{self.extension.name}" has no versions.'
|
|
||||||
raise BadRequest(error_message)
|
|
||||||
return super().dispatch(*args, **kwargs)
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user