Skip to content

Commit

Permalink
Modifie DeleteContent
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Jan 18, 2024
1 parent 45847a7 commit 809f8f9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions zds/tutorialv2/views/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,14 @@ def form_valid(self, form):

class DeleteContent(LoginRequiredMixin, SingleContentViewMixin, DeleteView):
model = PublishableContent
template_name = None
http_method_names = ["delete", "post"]
object = None
http_method_names = ["post"]
authorized_for_staff = False # deletion is creator's privilege

@method_decorator(transaction.atomic)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)

def delete(self, request, *args, **kwargs):
"""rewrite delete() function to ensure repository deletion"""

def form_valid(self, form):
self.object = self.get_object()
object_type = self.object.type.lower()

Expand Down Expand Up @@ -362,4 +358,4 @@ def delete(self, request, *args, **kwargs):

messages.success(self.request, _("Vous avez bien supprimé {}.").format(_type))

return redirect(reverse(object_type + ":find-" + object_type, args=[request.user.username]))
return redirect(reverse(object_type + ":find-" + object_type, args=[self.request.user.username]))

0 comments on commit 809f8f9

Please sign in to comment.