# 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 %}original_label{% endcomment %} Lien W Facette - Désactiver
le lien W - Supprimer
le lien W + Lien W activé + Supprimer
le lien W Alias Retirer le tag de la liste {% if ordered_tags %} {# ordered_tags is a list of TaggedSheet #} {% for t in ordered_tags %} - {{forloop.counter}}-{{t.order}} + {{forloop.counter}} {% if valid != "2" %} {% if not forloop.first %}up{% endif %} {% if not forloop.last %}down{% endif %} {% endif %} {{t.tag.id}} - {{t.tag.label}} + {{t.tag.label}} {% comment %}{{t.tag.original_label}}{% endcomment %} - + + {% if t.tag.wikipedia_url and t.tag.wikipedia_url != "" %} + + {% else %} + + {% endif %} - + {{t.tag.alias}} {{t.tag.label}} @@ -50,13 +55,18 @@ {% if not forloop.last %}down{% endif %} {% endif %} {{t.id}} - {{t.label}} + {{t.label}} {% comment %}{{t.original_label}}{% endcomment %} - + + {% if t.wikipedia_url and t.wikipedia_url != "" %} + + {% else %} + + {% endif %} facette - + - {{t.tag.alias}} + {{t.alias}} {{t.label}} {% endfor %} {% endif %} diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/urls.py --- a/web/hdabo/urls.py Thu Jun 09 18:52:02 2011 +0200 +++ b/web/hdabo/urls.py Fri Jun 10 16:43:38 2011 +0200 @@ -22,4 +22,5 @@ url(r'^list/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.list_for_orga'), url(r'^tagupdown$', 'hdabo.views.TagUpDown'), url(r'^removetagfromlist$', 'hdabo.views.RemoveTagFromList'), + url(r'^validatelink$', 'hdabo.views.ValidateWPLink'), ) diff -r 89782c9e96cf -r 65b887db0ff3 web/hdabo/views.py --- a/web/hdabo/views.py Thu Jun 09 18:52:02 2011 +0200 +++ b/web/hdabo/views.py Fri Jun 10 16:43:38 2011 +0200 @@ -125,7 +125,23 @@ # We get the current TaggedSheet and we delete it ts = ds_tags.filter(tag=Tag.objects.filter(id=tag_id))[0] ts.delete() - # We decrement the others tags's order + + return GetTagTable(request=request, ds_id=ds_id, valid=0) + + +#@login_required +def ValidateWPLink(request=None): + + ds_id = request.POST["datasheet_id"] + tag_id = request.POST["tag_id"] + if request.POST["activated"] != "false" : + wp_activ = True + else : + wp_activ = False + # First we get the tag object + tag = Tag.objects.filter(id=tag_id)[0] + tag.wikipedia_activated = wp_activ + tag.save() return GetTagTable(request=request, ds_id=ds_id, valid=0)