Make it possible to fully delete unlisted/unrated extensions #81
@ -361,6 +361,7 @@ 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()
|
||||||
|
if self.version:
|
||||||
initial['file'] = self.version.file
|
initial['file'] = self.version.file
|
||||||
initial.update(**self.version.file.parsed_version_fields)
|
initial.update(**self.version.file.parsed_version_fields)
|
||||||
return initial
|
return initial
|
||||||
|
@ -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