Skip to content

Commit

Permalink
Modifie DeleteImages en préparation pour Django 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Jan 14, 2024
1 parent 411bc88 commit bb31d33
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions zds/gallery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())


Expand Down

0 comments on commit bb31d33

Please sign in to comment.