Use ChosenViewMixin for image chosen view

pull/8931/head
Matt Westcott 2022-07-01 19:09:33 +01:00 zatwierdzone przez Matt Westcott
rodzic e831d8e6cc
commit da33faf220
2 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -39,7 +39,7 @@ urlpatterns = [
"chooser/results/", chooser.ChooseResultsView.as_view(), name="chooser_results"
),
path(
"chooser/<int:image_id>/",
"chooser/chosen/<str:pk>/",
chooser.ImageChosenView.as_view(),
name="image_chosen",
),

Wyświetl plik

@ -17,6 +17,7 @@ from wagtail.admin.views.generic.chooser import (
ChooseResultsViewMixin,
ChooseViewMixin,
ChosenResponseMixin,
ChosenViewMixin,
CreationFormMixin,
)
from wagtail.admin.views.generic.permissions import PermissionCheckedMixin
@ -187,10 +188,10 @@ class ChooseResultsView(
pass
class ImageChosenView(ImageChosenResponseMixin, View):
def get(self, request, image_id):
image = get_object_or_404(get_image_model(), id=image_id)
return self.get_chosen_response(image)
class ImageChosenView(ChosenViewMixin, ImageChosenResponseMixin, View):
def get(self, request, *args, pk, **kwargs):
self.model = get_image_model()
return super().get(request, *args, pk, **kwargs)
def duplicate_found(request, new_image, existing_image):