# HG changeset patch
# User cavaliet
# Date 1327417394 -3600
# Node ID ef326411c1fee56ba691dc35a4dee91ea11b9277
# Parent 9267376f58acbab7698de74e975973bc9c7310e8
Prepare url, front.py, js and template to load annotation preview.
diff -r 9267376f58ac -r ef326411c1fe src/ldt/ldt/ldt_utils/templates/front/front_search_results.html
--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 16:03:14 2012 +0100
@@ -33,6 +33,9 @@
"stats" : [{{ res.content.stat_annotation }}],
},{% endfor %}
];
+
+ var global_csrf_token = "{{ csrf_token }}";
+ var annot_preview_url = "{% url ldt.ldt_utils.views.front.annotation_preview content_iri_id='__CONTENT_IRI_ID__' project_id='__PROJECT_ID__' cutting_id='__CUTTING_ID__' annot_id='__ANNOT_ID__' %}";
diff -r 9267376f58ac -r ef326411c1fe src/ldt/ldt/ldt_utils/urls.py
--- a/src/ldt/ldt/ldt_utils/urls.py Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/urls.py Tue Jan 24 16:03:14 2012 +0100
@@ -48,6 +48,7 @@
url(r'^front/search/$', 'views.front.search_index'),
url(r'^front/searchListing', 'views.front.search_listing'),
url(r'^front/medias', 'views.front.all_contents'),
+ url(r'^annotpreview/(?P.*)/(?P.*)/(?P.*)/(?P.*)$', 'views.front.annotation_preview'),
)
urlpatterns += patterns('',
diff -r 9267376f58ac -r ef326411c1fe src/ldt/ldt/ldt_utils/views/front.py
--- a/src/ldt/ldt/ldt_utils/views/front.py Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py Tue Jan 24 16:03:14 2012 +0100
@@ -2,7 +2,7 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import Group, User
from django.core.urlresolvers import reverse
-from django.http import HttpResponseServerError
+from django.http import HttpResponse, HttpResponseServerError
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from guardian.shortcuts import get_objects_for_group
@@ -129,4 +129,11 @@
return Tag.objects.cloud_for_model(Content, steps=steps)[:limit]
+def annotation_preview(request, content_iri_id, project_id, cutting_id, annot_id):
+ return HttpResponse("coucou
content_iri_id = " + content_iri_id +
+ "
project_id = " + project_id +
+ "
cutting_id = " + cutting_id +
+ "
annot_id = " + annot_id)
+
+
diff -r 9267376f58ac -r ef326411c1fe src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js
--- a/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Tue Jan 24 16:03:14 2012 +0100
@@ -71,5 +71,20 @@
}).css({
"opacity" : ".5",
});
+ }).click(function() {
+ var url = annot_preview_url.replace('__CONTENT_IRI_ID__', "ctt_iri_id");
+ url = url.replace('__PROJECT_ID__', "project_id");
+ url = url.replace('__CUTTING_ID__', "cutting_id");
+ url = url.replace('__ANNOT_ID__', "annot_id");
+ $.ajax({
+ url: url,
+ type: 'GET',
+ data: {csrfmiddlewaretoken:global_csrf_token},
+ // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType
+ //dataType: 'json',
+ success: function(data, status, request) {
+ $("#result_preview").html(data);
+ }
+ });
});
});
\ No newline at end of file