Skip to content

Commit

Permalink
Views delete
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishwillee committed Nov 3, 2023
1 parent d9077aa commit 394c331
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ class BookDelete(PermissionRequiredMixin, DeleteView):
success_url = reverse_lazy('books')
permission_required = 'catalog.can_mark_returned'

def form_valid(self, form):
print("you all suck")
try:
self.object.delete()
return HttpResponseRedirect(self.success_url)
except Exception as e:
return HttpResponseRedirect(
reverse("book-delete", kwargs={"pk": self.object.pk})
)

class GenreCreate(PermissionRequiredMixin, CreateView):
model = Genre
Expand Down

0 comments on commit 394c331

Please sign in to comment.