diff --git a/photologue/templates/photologue/photo_confirm_delete.html b/photologue/templates/photologue/photo_confirm_delete.html
new file mode 100644
index 0000000..29c88d9
--- /dev/null
+++ b/photologue/templates/photologue/photo_confirm_delete.html
@@ -0,0 +1,24 @@
+{% extends "base.html" %}
+{% comment %}
+SPDX-License-Identifier: GPL-3.0-or-later
+{% endcomment %}
+{% load i18n %}
+
+{% block title %}{% trans "Delete confirmation" %}{% endblock %}
+
+{% block content %}
+
+
+
{% trans "Delete confirmation" %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/photologue/urls.py b/photologue/urls.py
index 5169131..547b0f0 100644
--- a/photologue/urls.py
+++ b/photologue/urls.py
@@ -2,7 +2,7 @@ from django.urls import path, re_path
from .views import (GalleryDetailView, GalleryArchiveIndexView,
GalleryDownload, GalleryUpload, GalleryYearArchiveView,
- PhotoDetailView, TagDetail)
+ PhotoDetailView, PhotoDeleteView, TagDetail)
app_name = 'photologue'
urlpatterns = [
@@ -13,5 +13,6 @@ urlpatterns = [
path('gallery///', GalleryDetailView.as_view(), name='pl-gallery-owner'),
path('gallery//download/', GalleryDownload.as_view(), name='pl-gallery-download'),
path('photo//', PhotoDetailView.as_view(), name='pl-photo'),
+ path('photo//delete/', PhotoDeleteView.as_view(), name='pl-photo-delete'),
path('upload/', GalleryUpload.as_view(), name='pl-gallery-upload'),
]
diff --git a/photologue/views.py b/photologue/views.py
index 8d75d87..75621ca 100644
--- a/photologue/views.py
+++ b/photologue/views.py
@@ -16,7 +16,7 @@ from django.urls import reverse_lazy
from django.utils.text import slugify
from django.views.generic.dates import ArchiveIndexView, YearArchiveView
from django.views.generic.detail import DetailView
-from django.views.generic.edit import FormView
+from django.views.generic.edit import FormView, DeleteView
from PIL import Image
from .forms import UploadForm
@@ -56,6 +56,18 @@ class PhotoDetailView(LoginRequiredMixin, DetailView):
return qs.filter(is_public=True)
+class PhotoDeleteView(PermissionRequiredMixin, DeleteView):
+ model = Photo
+ permission_required = 'photologue.delete_photo'
+
+ def get_success_url(self):
+ galleries = self.object.galleries.all()
+ if not galleries:
+ return reverse_lazy('photologue:pl-gallery-archive')
+ slug = galleries[0].slug
+ return reverse_lazy('photologue:pl-gallery', args=[slug])
+
+
class TagDetail(LoginRequiredMixin, DetailView):
model = Tag