# HG changeset patch # User cavaliet # Date 1307717018 -7200 # Node ID 65b887db0ff3c10fc8df46a86beab00eb188f35c # Parent 89782c9e96cf450b1bebebd64087cb7f3f45bc0e Set good css style for status link. Add png for link calling wikipedia search. Enable to validate/unvalidate a wp link for a tag via ajax. diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/models.py --- a/web/hdabo/models.py Thu Jun 09 18:52:02 2011 +0200 +++ b/web/hdabo/models.py Fri Jun 10 16:43:38 2011 +0200 @@ -92,6 +92,13 @@ dbpedia_uri = models.URLField(verify_exists=False, max_length=512, blank=True, null=True) wikipedia_activated = models.BooleanField(default=False) + @Property + def url_status_text(): #@NoSelf + def fget(self): + return self.TAG_URL_STATUS_CHOICES[self.url_status][1] + + return locals() + class TagCategory(models.Model): label = models.CharField(max_length=512, unique=True, blank=False, null=False) diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/static/hdabo/css/style.css --- a/web/hdabo/static/hdabo/css/style.css Thu Jun 09 18:52:02 2011 +0200 +++ b/web/hdabo/static/hdabo/css/style.css Fri Jun 10 16:43:38 2011 +0200 @@ -346,3 +346,22 @@ .text_centered { text-align: center; } + +/* styles for the 4 types of STATUS*/ +.null_result { + color: #000000; +} +.redirection { + color: #0000ff; + font-weight: bold; + font-style: italic; +} +.homonyme { + color: #000000; + font-weight: bold; +} +.match { + color: #0000ff; + font-weight: bold; +} + diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/static/hdabo/img/wikipedia_search.png Binary file web/hdabo/static/hdabo/img/wikipedia_search.png has changed diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/static/hdabo/js/hdabo.js --- a/web/hdabo/static/hdabo/js/hdabo.js Thu Jun 09 18:52:02 2011 +0200 +++ b/web/hdabo/static/hdabo/js/hdabo.js Fri Jun 10 16:43:38 2011 +0200 @@ -10,6 +10,45 @@ remove_tag_from_list(this); } }); + //activate_wp_cb + $(".activate_wp_cb").click(function(e){ + new_checked = $(this).is(':checked'); + if(new_checked){ + question = "Confirmez-vous l'activation du lien Wikipédia pour le tag \"" + $(this).attr('alt') + "\" ?"; + } else { + question = "Confirmez-vous la désactivation du lien Wikipédia pour le tag \"" + $(this).attr('alt') + "\" ?"; + } + if(confirm(question)){ + validate_wp_link(this); + } + else{ + // Since the click event is dispatched after the checked changed, we change the checked changed if confirm is false. + e.preventDefault(); // unvalidates user's click + $(this).attr('checked', !new_checked); + } + }); +} + +function validate_wp_link(cb) +{ + var url = validate_wp_link_url; + var id_tag = $(cb).attr('id'); + new_checked = $(cb).is(':checked'); + $.ajax({ + url: url, + type: 'POST', + data: {csrfmiddlewaretoken:global_csrf_token, + datasheet_id:$('#datasheet_id').val(), + tag_id:id_tag, + activated:new_checked + }, + // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType + //dataType: 'json', + success: function(msg, textStatus, XMLHttpRequest) { + $('#tag_table_container').html(msg); + init_tags_events(); + } + }); } function remove_tag_from_list(btn) @@ -19,7 +58,7 @@ $.ajax({ url: url, type: 'POST', - data: {csrfmiddlewaretoken:global_csrf_token, + data: {csrfmiddlewaretoken:global_csrf_token, datasheet_id:$('#datasheet_id').val(), tag_id:id_tag }, diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/templates/partial/list_for_orga.html --- a/web/hdabo/templates/partial/list_for_orga.html Thu Jun 09 18:52:02 2011 +0200 +++ b/web/hdabo/templates/partial/list_for_orga.html Fri Jun 10 16:43:38 2011 +0200 @@ -9,6 +9,7 @@ var global_csrf_token = "{{ csrf_token }}"; var tag_up_down_url = "{% url hdabo.views.TagUpDown %}"; var remove_tag_from_list_url = "{% url hdabo.views.RemoveTagFromList %}"; + var validate_wp_link_url = "{% url hdabo.views.ValidateWPLink %}"; $(document).ready(function(){ init_tags_events(); diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/templates/partial/tag_table.html --- a/web/hdabo/templates/partial/tag_table.html Thu Jun 09 18:52:02 2011 +0200 +++ b/web/hdabo/templates/partial/tag_table.html Fri Jun 10 16:43:38 2011 +0200 @@ -10,23 +10,28 @@ {% comment %}
{% endif %}
{% endif %}
+ {% else %}
+
+ {% endif %}

{% endif %}
+ {% else %}
+
+ {% endif %}
