From ec54aa0457966f037e3be549df16c4713175ddcb Mon Sep 17 00:00:00 2001
From: Pablo Silva
Date: Sun, 8 Dec 2024 18:18:50 +0000
Subject: [PATCH] Fix API output usage on ajax requests
---
.../users/components/elements-modal.jinja2 | 24 +++++++++----------
tasks.py | 1 +
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/users/jinja2/users/components/elements-modal.jinja2 b/src/users/jinja2/users/components/elements-modal.jinja2
index ae554b00..89dc7760 100644
--- a/src/users/jinja2/users/components/elements-modal.jinja2
+++ b/src/users/jinja2/users/components/elements-modal.jinja2
@@ -21,7 +21,7 @@
$('#element-upload-info').replaceWith(
'' +
{{ _("Uploaded by ")|tojson }} +
- owner + ', ' +
+ owner.username + ', ' +
{{ _("in ")|tojson }} + new Date(date).toLocaleDateString() + '
'
)
}
@@ -36,11 +36,12 @@
'
'
)
}
- function usedInExhibit(marker_id, object_id, exhibits_count, marker_src, augmented_src, element_id){
+ function usedInExhibit(marker_id, object_id, exhibits_count, marker, augmented, element_id){
let object_tag = ''
+ let augmented_src = augmented.source
if(augmented_src.split('.')[1] == 'mp4' || augmented_src.split('.')[1] == 'webm'){
object_tag = ''
- }else{
+ } else {
object_tag = ''
}
@@ -49,7 +50,7 @@
{{ _(" Used in ")|tojson }} + '' +
exhibits_count +
{{ _(" Exhibits")|tojson }} + '' +
- '' +
+ '' +
object_tag
)
$('.trigger-erase').click(eraseModal);
@@ -65,7 +66,7 @@
}else{
$('#element-download').replaceWith(
'' +
- 'Download .gif (' + file_size + ' kb)
'
+ 'Download .gif (' + file_size + ' kb)'
)
}
}
@@ -113,14 +114,13 @@
$('#create-artwork').text(
{{ _('Create artwork with this ')|tojson }} + elemType
);
-
$.ajax({
url: elemUrl,
success: function(data){
- elementAuthor(data['author'], data['owner_id']);
+ elementAuthor(data['author']);
uploadedBy(data['owner'], data['uploaded_at']);
- usedIn(data['artworks'], data['exhibits'], data['source'], element_id, elemType);
- downloadElement(data['type'], data['size']/1000, data['source']);
+ usedIn(data['artworks_count'], data['exhibits_count'], data['source'], element_id, elemType);
+ downloadElement(data['type'], data["source_size"]/1000, data['source']);
}
});
}else{
@@ -128,10 +128,10 @@
$.ajax({
url: elemUrl,
success: function(data){
- elementAuthor(data['author'], data['owner_id']);
- usedInExhibit(data['id_marker'], data['id_object'], data['exhibits'], data['marker'], data['augmented'], element_id);
+ elementAuthor(data['author'].username);
+ usedInExhibit(data['id_marker'], data['id_object'], data['exhibits_count'], data['marker'], data['augmented'], element_id);
replaceButtons(data['title'], data['description']);
- downloadElement(data['type'], data['augmented_size']/1000, data['augmented']);
+ downloadElement(data['type'], data['augmented'].source_size/1000, data['augmented'].source);
}
});
}
diff --git a/tasks.py b/tasks.py
index 84e85342..2a5f782d 100644
--- a/tasks.py
+++ b/tasks.py
@@ -25,6 +25,7 @@ def manage(ctx, cmd):
cmd = f"python3 ./src/manage.py {cmd}"
ctx.run(cmd, pty=True, env=os.environ)
+
#
# Translations
#