From 908aecce1582f02a7bda6081d3b445e9fec5e557 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 28 Mar 2025 12:03:30 +0000 Subject: [PATCH] add edit link --- camp/static/css/site.scss | 13 +++++++++++-- camp/static/js/gallery.js | 12 +++++++++++- content/templates/gallery.html | 7 ++++++- photologue/models.py | 3 +++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/camp/static/css/site.scss b/camp/static/css/site.scss index 7797db8..47416a9 100644 --- a/camp/static/css/site.scss +++ b/camp/static/css/site.scss @@ -93,7 +93,8 @@ .close:hover { color: white !important; } - .download.disabled { + .download.disabled, + .edit.disabled { display: none; } .download { @@ -104,7 +105,15 @@ right: 24px } - .download:hover { + .edit { + color: lightgray !important; + cursor: pointer; + position: absolute; + top: 4px; + left: 4px + } + .download:hover, + .edit:hover { color: white !important; } @media screen and (max-width: 39.9375em) { diff --git a/camp/static/js/gallery.js b/camp/static/js/gallery.js index 470ca23..9fa5068 100644 --- a/camp/static/js/gallery.js +++ b/camp/static/js/gallery.js @@ -28,7 +28,8 @@ function loadGalleries() { let photo = { src: src, caption: img.dataset.caption, - orig: img.dataset.orig + orig: img.dataset.orig, + edit: img.dataset.edit } photos.push(photo) img.parentElement.addEventListener("click", event => { @@ -82,6 +83,7 @@ function loadGallery(images, idx, main, thumbnails) { + @@ -111,6 +113,7 @@ function loadGallery(images, idx, main, thumbnails) { const prevBtn = gallery.querySelector(".prev.nav-btn"); const nextBtn = gallery.querySelector(".next.nav-btn"); const download = gallery.querySelector(".download"); + const edit = gallery.querySelector(".edit"); let thumbnailsContainer if (idx != 'inline') { thumbnailsContainer = gallery.querySelector(".thumbnails"); @@ -153,6 +156,13 @@ function loadGallery(images, idx, main, thumbnails) { download.href = "" download.classList.add('disabled') } + if (images[index].edit) { + edit.href = images[index].edit + edit.classList.remove('disabled') + } else { + edit.href = "" + edit.classList.add('disabled') + } prevBtn.disabled = index === 0; nextBtn.disabled = index === images.length - 1; if (idx == 'inline') { diff --git a/content/templates/gallery.html b/content/templates/gallery.html index b374220..8901111 100644 --- a/content/templates/gallery.html +++ b/content/templates/gallery.html @@ -2,7 +2,12 @@
{{gallery.title}}
{% endif %} diff --git a/photologue/models.py b/photologue/models.py index c621a6b..13a4194 100644 --- a/photologue/models.py +++ b/photologue/models.py @@ -597,6 +597,9 @@ class Photo(ImageModel): return mark_safe(markdownify(caption)) return caption + def edit_url(self): + return '/admin/photologue/photo/%s/change/' % self.id + class BaseEffect(models.Model): name = models.CharField(_('name'), max_length=30,