diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/photos/admin.py | 2 | ||||
-rw-r--r-- | app/photos/models.py | 2 | ||||
-rw-r--r-- | app/photos/static/image-preview.js | 59 |
3 files changed, 32 insertions, 31 deletions
diff --git a/app/photos/admin.py b/app/photos/admin.py index a052169..d2c86d8 100644 --- a/app/photos/admin.py +++ b/app/photos/admin.py @@ -52,7 +52,7 @@ class LuxImageAdmin(OSMGeoAdmin): ) class Media: - js = ('image-preview.js',) + js = ('image-preview.js', 'next-prev-links.js') admin.site.register(LuxImage, LuxImageAdmin) diff --git a/app/photos/models.py b/app/photos/models.py index 91ac15d..eece991 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -7,6 +7,8 @@ from django.core.exceptions import ValidationError from django.contrib.gis.db import models from django.contrib.sitemaps import Sitemap from django.utils.encoding import force_text +from django.urls import reverse +from django.apps import apps from django.utils.html import format_html from django.utils.text import slugify from django.conf import settings diff --git a/app/photos/static/image-preview.js b/app/photos/static/image-preview.js index aac9c0b..277def3 100644 --- a/app/photos/static/image-preview.js +++ b/app/photos/static/image-preview.js @@ -2,37 +2,36 @@ function build_image_preview () { var url = window.location.href var cur = url.split('/')[6]; if (cur) { - var container = document.createElement("div"); - container.className = "form-row field-image"; - var wrapper = document.createElement("div"); - var label = document.createElement("label"); - label.textContent = "Image:"; - var pwrap = document.createElement("p"); - var img = document.createElement("img"); + var container = document.createElement("div"); + container.className = "form-row field-image"; + var wrapper = document.createElement("div"); + var label = document.createElement("label"); + label.textContent = "Image:"; + var pwrap = document.createElement("p"); + var img = document.createElement("img"); - var request = new XMLHttpRequest(); - request.open('GET', '/photos/luximage/data/admin/preview/'+cur+'/', true); - request.onload = function() { - if (request.status >= 200 && request.status < 400) { - var data = JSON.parse(request.responseText); - //console.log(resp); - img.src = data['url']; - } else { - console.log("server error"); - } - }; - request.onerror = function() { - console.log("error on request"); - }; - request.send(); - - pwrap.appendChild(img); - wrapper.appendChild(label); - wrapper.appendChild(pwrap); - container.appendChild(wrapper); - parent = document.getElementById("luximage_form"); - node = parent.children[1].children[0]; - node.parentNode.insertBefore(container, node.previousSibling); + var request = new XMLHttpRequest(); + request.open('GET', '/photos/luximage/data/admin/preview/'+cur+'/', true); + request.onload = function() { + if (request.status >= 200 && request.status < 400) { + var data = JSON.parse(request.responseText); + console.log(data); + img.src = data['url']; + } else { + console.log("server error"); + } + }; + request.onerror = function() { + console.log("error on request"); + }; + request.send(); + pwrap.appendChild(img); + wrapper.appendChild(label); + wrapper.appendChild(pwrap); + container.appendChild(wrapper); + parent = document.getElementById("luximage_form"); + node = parent.children[1].children[0]; + node.parentNode.insertBefore(container, node.previousSibling); } else { return; } |