diff --git a/quackscape/users/templates/users/category.html b/quackscape/users/templates/users/category.html index 8626725..ce4e605 100644 --- a/quackscape/users/templates/users/category.html +++ b/quackscape/users/templates/users/category.html @@ -98,7 +98,9 @@ {{ scene.title }} - + + + {% endfor %} diff --git a/quackscape/users/urls.py b/quackscape/users/urls.py index e42a3aa..ab62680 100644 --- a/quackscape/users/urls.py +++ b/quackscape/users/urls.py @@ -9,6 +9,7 @@ from .views import ( CategoryDeleteView, CategoryUpdateView, MediaDeleteView, + SceneDeleteView, ) from django.urls import path @@ -40,6 +41,11 @@ urlpatterns = [ MediaDeleteView.as_view(), name="media-delete", ), + path( + "category//scene//delete/", + SceneDeleteView.as_view(), + name="scene-delete", + ), path("login/", Login.as_view(), name="login"), path("logout/", Logout.as_view(), name="logout"), ] diff --git a/quackscape/users/views.py b/quackscape/users/views.py index 4294da1..c3e429c 100644 --- a/quackscape/users/views.py +++ b/quackscape/users/views.py @@ -171,7 +171,29 @@ class MediaDeleteView(LoginRequiredMixin, TitleMixin, DeleteView): raise Http404() def get_success_url(self): - return reverse_lazy("quackscape.users:category", kwargs={"category": self.kwargs["category"]}) + return reverse_lazy( + "quackscape.users:category", kwargs={"category": self.kwargs["category"]} + ) + + +class SceneDeleteView(LoginRequiredMixin, TitleMixin, DeleteView): + template_name = "users/generic_delete.html" + title = "Delete Scene" + model = OriginalMedia + + def get_object(self): + try: + media = OriginalMedia.objects.get(id=self.kwargs["media"]) + assert media.user_has_permission(self.request.user) + return media + except (OriginalMedia.DoesNotExist, AssertionError): + raise Http404() + + def get_success_url(self): + return reverse_lazy( + "quackscape.users:category", kwargs={"category": self.kwargs["category"]} + ) + class Login(TitleMixin, LoginView): title = "Login"