From bb31d33eb2c8d2c84bbbc143d266b877390629f5 Mon Sep 17 00:00:00 2001 From: Arnaud-D <35631001+Arnaud-D@users.noreply.github.com> Date: Sun, 15 Oct 2023 21:25:00 +0200 Subject: [PATCH] =?UTF-8?q?Modifie=20DeleteImages=20en=20pr=C3=A9paration?= =?UTF-8?q?=20pour=20Django=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zds/gallery/views.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/zds/gallery/views.py b/zds/gallery/views.py index c652836063..f8eed8c4b5 100644 --- a/zds/gallery/views.py +++ b/zds/gallery/views.py @@ -398,24 +398,23 @@ def form_valid(self, form): return super().form_valid(form) -class DeleteImages(ImageFromGalleryViewMixin, ImageUpdateOrDeleteMixin, LoggedWithReadWriteHability, DeleteView): +class DeleteImages(ImageFromGalleryViewMixin, ImageUpdateOrDeleteMixin, LoggedWithReadWriteHability, View): """Delete a given image""" model = Image - http_method_names = ["post", "delete"] + http_method_names = ["post"] must_write = True - def delete(self, request, *args, **kwargs): + def post(self, request, *args, **kwargs): if "delete_multi" in request.POST: list_items = request.POST.getlist("g_items") Image.objects.filter(pk__in=list_items, gallery=self.gallery).delete() elif "delete" in request.POST: try: - self.get_image(self.request.POST.get("image")) + self.get_image(request.POST.get("image")) self.perform_delete() except Image.DoesNotExist: raise Http404() - return redirect(self.gallery.get_absolute_url())