# HG changeset patch
# User cavaliet
# Date 1362415257 -3600
# Node ID 4d320fbfc5503d593cf0322554a4b5cadf191a54
# Parent b2fbd34b259c918dd988acbe129fb4084a8a45d2
Prepare front for Senseetive api.
diff -r b2fbd34b259c -r 4d320fbfc550 src/egonomy/admin.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/egonomy/admin.py Mon Mar 04 17:40:57 2013 +0100
@@ -0,0 +1,7 @@
+from django.contrib import admin
+from egonomy.models import Image, ImageInfo, ImageMetadata, Fragment
+
+admin.site.register(Image)
+admin.site.register(ImageInfo)
+admin.site.register(ImageMetadata)
+admin.site.register(Fragment)
diff -r b2fbd34b259c -r 4d320fbfc550 src/egonomy/static/egonomy/css/egonomy.css
--- a/src/egonomy/static/egonomy/css/egonomy.css Mon Mar 04 15:29:30 2013 +0100
+++ b/src/egonomy/static/egonomy/css/egonomy.css Mon Mar 04 17:40:57 2013 +0100
@@ -328,6 +328,10 @@
background: #D0E0FF; margin: 5px 0; padding: 6px; border-radius: 4px; color: #003366;
font-weight: bold; font-size: 13px; float: left;
}
+.add-button-grey {
+ background: #AAAAAA; margin: 5px 0; padding: 6px; border-radius: 4px; color: #555555;
+ font-weight: bold; font-size: 13px; float: left;
+}
.big-button {
background: #D0E0FF; margin: 10px 0 10px 16px; padding: 8px; border-radius: 4px; color: #003366;
diff -r b2fbd34b259c -r 4d320fbfc550 src/egonomy/static/egonomy/js/cutout.js
--- a/src/egonomy/static/egonomy/js/cutout.js Mon Mar 04 15:29:30 2013 +0100
+++ b/src/egonomy/static/egonomy/js/cutout.js Mon Mar 04 17:40:57 2013 +0100
@@ -178,7 +178,7 @@
var transd = "M"
+ points.map(function(p) { return (p.x / paper.width).toString().replace(/(\.\d{4})\d*/,"$1") + " " + (p.y / paper.height).toString().replace(/(\.\d{4})\d*/,"$1") }).join("L")
+ "Z";
- $(".fragment-path").val(transd);
+ $(".fragment-path").val(transd).change();
}
var dragdeltax, dragdeltay, pathDragging;
diff -r b2fbd34b259c -r 4d320fbfc550 src/egonomy/templates/egonomy_create_fragment.html
--- a/src/egonomy/templates/egonomy_create_fragment.html Mon Mar 04 15:29:30 2013 +0100
+++ b/src/egonomy/templates/egonomy_create_fragment.html Mon Mar 04 17:40:57 2013 +0100
@@ -42,9 +42,17 @@
addTags($("#pertimm_thesaurus_tags").text().split(', '));
});
}
- // Function to add one tag
- $(".addable_tag").click(function() {
- addTags([$(this).text()])
+ // Check if path is not empty ("" or "MZ")
+ $(".fragment-path").change(function() {
+ var v = $(".fragment-path").val();
+ if(v!="" && v!="MZ"){
+ $("#senseetive_click").removeClass("add-button-grey");
+ $("#senseetive_click").addClass("clickable add-button");
+ }
+ else{
+ $("#senseetive_click").addClass("add-button-grey");
+ $("#senseetive_click").removeClass("clickable add-button");
+ }
});
// Init tagit autocomplete with tags from various sources
autocomplete_tags = $("#rmn_tags").text().split(', ');
@@ -52,6 +60,49 @@
autocomplete_tags = autocomplete_tags.concat($("#pertimm_description_tags").text().split(', '));
autocomplete_tags = autocomplete_tags.concat($("#pertimm_thesaurus_tags").text().split(', '));
$('#user_keywords').tagit({availableTags: autocomplete_tags, allowSpaces: true});
+
+ // Function to add one tag
+ $(".addable_tag").click(function() {
+ addTags([$(this).text()]);
+ });
+
+ // Init senseetive api request
+ if($("#senseetive_click")){
+ $("#senseetive_click").click(function() {
+ var v = $(".fragment-path").val();
+ if(v!="" && v!="MZ"){
+ var data_obj = { "image":"{{ img.id }}", "path":$("#fragment_path").val() };
+ $.ajax({
+ url: '{% url "senseetive_api" %}',
+ data: data_obj,
+ dataType: "json",
+ success: function(data, status, request){
+ var n = data.length;
+ if(n>0){
+ s = '';
+ if(i<(n-1)) s += ', ';
+ }
+ s += '
';
+ $("#senseetive_holder").html(s);
+ // Function to add one tag
+ $("#senseetive_holder .addable_tag").click(function() {
+ addTags([$(this).text()]);
+ });
+ // Functions to add all tags from senseetive
+ $("#senseetive_tags").click(function() {
+ addTags($("#add_senseetive_tags").text().split(', '));
+ });
+ }
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ $("#senseetive_holder").html("ERROR : " + jqXHR.responseText);
+ }
+ });
+ }
+ });
+ }
};
function addTags(tags){
nt = tags.length;
@@ -140,6 +191,10 @@
+ {% trans 'Add all Pertimm thesaurus keywords to yours' %}
{% endif %}
+
{% trans 'Request keywords from Senseetive API' %}