Always load lg-admin plugin

This commit is contained in:
Alexandre Iooss 2022-03-01 21:06:58 +01:00
parent 6376e3b550
commit 695ec94d7c
2 changed files with 4 additions and 1 deletions

View file

@ -8,6 +8,7 @@ class lgAdmin {
constructor(instance, $LG) {
this.core = instance;
this.$LG = $LG;
this.isStaff = instance.settings.isStaff;
return this;
}
@ -19,6 +20,7 @@ class lgAdmin {
onAfterSlide(event) {
const photoId = this.core.galleryItems[event.detail.index].slideName;
document.getElementById("lg-admin").href = `https://photos.crans.org/admin/photologue/photo/${photoId}/change/`;
document.getElementById("lg-admin").style.display = this.isStaff ? 'block' : 'none';
}
// Admin must have destroy prototype

View file

@ -20,8 +20,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
<script src="{% static 'lightgallery/plugins/zoom/lg-zoom.min.js' %}"></script>
<script>
lightGallery(document.getElementById('lightgallery'), {
plugins: [{% if request.user.is_staff %}lgAdmin, {% endif %}lgHash, lgThumbnail, lgZoom],
plugins: [lgAdmin, lgHash, lgThumbnail, lgZoom],
customSlideName: true,
isStaff: {{ request.user.is_staff|yesno:"true,false" }},
});
</script>
{% endblock %}