add edit link

This commit is contained in:
j 2025-03-28 12:03:30 +00:00
parent d580ec92f6
commit 908aecce15
4 changed files with 31 additions and 4 deletions

View file

@ -93,7 +93,8 @@
.close:hover { .close:hover {
color: white !important; color: white !important;
} }
.download.disabled { .download.disabled,
.edit.disabled {
display: none; display: none;
} }
.download { .download {
@ -104,7 +105,15 @@
right: 24px right: 24px
} }
.download:hover { .edit {
color: lightgray !important;
cursor: pointer;
position: absolute;
top: 4px;
left: 4px
}
.download:hover,
.edit:hover {
color: white !important; color: white !important;
} }
@media screen and (max-width: 39.9375em) { @media screen and (max-width: 39.9375em) {

View file

@ -28,7 +28,8 @@ function loadGalleries() {
let photo = { let photo = {
src: src, src: src,
caption: img.dataset.caption, caption: img.dataset.caption,
orig: img.dataset.orig orig: img.dataset.orig,
edit: img.dataset.edit
} }
photos.push(photo) photos.push(photo)
img.parentElement.addEventListener("click", event => { img.parentElement.addEventListener("click", event => {
@ -82,6 +83,7 @@ function loadGallery(images, idx, main, thumbnails) {
<button class="next nav-btn">Next </button> <button class="next nav-btn">Next </button>
</div> </div>
<button class="close">&#10006;</button> <button class="close">&#10006;</button>
<a class="edit disabled" target="_blank" title="edit">&#9998;</a>
<a class="download disabled" target="_blank" download title="download original"> <a class="download disabled" target="_blank" download title="download original">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 304 384"><path fill="currentColor" d="M299 128L149 277L0 128h85V0h128v128h86zM0 320h299v43H0v-43z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 304 384"><path fill="currentColor" d="M299 128L149 277L0 128h85V0h128v128h86zM0 320h299v43H0v-43z"/></svg>
</a> </a>
@ -111,6 +113,7 @@ function loadGallery(images, idx, main, thumbnails) {
const prevBtn = gallery.querySelector(".prev.nav-btn"); const prevBtn = gallery.querySelector(".prev.nav-btn");
const nextBtn = gallery.querySelector(".next.nav-btn"); const nextBtn = gallery.querySelector(".next.nav-btn");
const download = gallery.querySelector(".download"); const download = gallery.querySelector(".download");
const edit = gallery.querySelector(".edit");
let thumbnailsContainer let thumbnailsContainer
if (idx != 'inline') { if (idx != 'inline') {
thumbnailsContainer = gallery.querySelector(".thumbnails"); thumbnailsContainer = gallery.querySelector(".thumbnails");
@ -153,6 +156,13 @@ function loadGallery(images, idx, main, thumbnails) {
download.href = "" download.href = ""
download.classList.add('disabled') 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; prevBtn.disabled = index === 0;
nextBtn.disabled = index === images.length - 1; nextBtn.disabled = index === images.length - 1;
if (idx == 'inline') { if (idx == 'inline') {

View file

@ -2,7 +2,12 @@
<h6><strong>{{gallery.title}}</strong></h6> <h6><strong>{{gallery.title}}</strong></h6>
<ul class="clearing-thumbs gallery" data-clearing> <ul class="clearing-thumbs gallery" data-clearing>
{% for photo in gallery.public %} {% for photo in gallery.public %}
<li><a href="{{ gallery.get_absolute_url }}#{{forloop.counter}}"><img src="{{ photo.get_thumbnail_url }}" class="photo" data-caption="{{ photo.caption_html }}"{% if request.user.is_staff %} data-orig="{{ photo.image.url }}"{% endif %}></a></li> <li><a href="{{ gallery.get_absolute_url }}#{{forloop.counter}}"><img src="{{ photo.get_thumbnail_url }}"
class="photo"
data-caption="{{ photo.caption_html }}"
{% if request.user.is_staff %}data-orig="{{ photo.image.url }}"{% endif %}
{% if request.user.is_staff %}data-edit="{{ photo.edit_url }}"{% endif %}
></a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}

View file

@ -597,6 +597,9 @@ class Photo(ImageModel):
return mark_safe(markdownify(caption)) return mark_safe(markdownify(caption))
return caption return caption
def edit_url(self):
return '/admin/photologue/photo/%s/change/' % self.id
class BaseEffect(models.Model): class BaseEffect(models.Model):
name = models.CharField(_('name'), name = models.CharField(_('name'),
max_length=30, max_length=30,