This commit is contained in:
Ross
2021-11-22 20:18:34 +00:00
parent a4abfac31f
commit a32fb2c89b
4 changed files with 56 additions and 25 deletions
+4
View File
@@ -793,3 +793,7 @@ input {
height: 1000px; height: 1000px;
max-width: 1000px; max-width: 1000px;
} }
.image-duplicate {
border: 2px solid orange;
}
+26 -3
View File
@@ -569,7 +569,7 @@
}) })
} }
const viewLoadChecker = setInterval(function() { const viewLoadChecker = setInterval(function () {
if (load_viewer) { if (load_viewer) {
load_viewer = false; load_viewer = false;
loadViewer(); loadViewer();
@@ -632,7 +632,7 @@
} }
function checkHash(hash) { function checkHash(hash, input) {
$.ajax({ $.ajax({
url: "{% url 'rapids:rapid_question_by_hash' %}", url: "{% url 'rapids:rapid_question_by_hash' %}",
data: { data: {
@@ -650,7 +650,30 @@
console.log("success"); console.log("success");
console.log(data.id) console.log(data.id)
if (data.id) { if (data.id) {
toastr.info(`id ${data.id}`) //toastr.info(`id ${data.id}`)
uploading_el = $(`img[data-input-id='${input.id}'], div[data-input-id='${input.id}']`)
$(input).addClass("image-duplicate");
uploading_el.addClass("image-duplicate");
toastr.warning(`Image (${input.files[0].name}) already exists.<br /><a href='${data.url}'>Click to view</a><br /><button type="button" class="btn clear">Dismiss</button>`, "Duplicate image", {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-full-width",
"preventDuplicates": false,
"onclick": null,
"showDuration": "0",
"hideDuration": "0",
"timeOut": 0,
"extendedTimeOut": 0,
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut",
"tapToDismiss": false
})
} }
} }
}) })
+1 -1
View File
@@ -1115,7 +1115,7 @@ def get_question_by_hash(request):
try: try:
question = RapidImage.objects.get(image_md5_hash=hash) question = RapidImage.objects.get(image_md5_hash=hash)
data = {"status": "success", "id": question.pk} data = {"status": "success", "id": question.pk, "url": question.get_absolute_url()}
return JsonResponse(data, status=200) return JsonResponse(data, status=200)
except RapidImage.DoesNotExist: except RapidImage.DoesNotExist:
data = {"status": "success", "id": False} data = {"status": "success", "id": False}
+4
View File
@@ -793,3 +793,7 @@ input {
height: 1000px; height: 1000px;
max-width: 1000px; max-width: 1000px;
} }
.image-duplicate {
border: 2px solid orange;
}