--- a/web/hdabo/models.py Fri Jun 10 20:53:40 2011 +0200
+++ b/web/hdabo/models.py Fri Jun 10 20:57:45 2011 +0200
@@ -92,6 +92,13 @@
dbpedia_uri = models.URLField(verify_exists=False, max_length=2048, 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)
--- a/web/hdabo/static/hdabo/css/style.css Fri Jun 10 20:53:40 2011 +0200
+++ b/web/hdabo/static/hdabo/css/style.css Fri Jun 10 20:57:45 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;
+}
+
Binary file web/hdabo/static/hdabo/img/wikipedia_search.png has changed
--- a/web/hdabo/static/hdabo/js/hdabo.js Fri Jun 10 20:53:40 2011 +0200
+++ b/web/hdabo/static/hdabo/js/hdabo.js Fri Jun 10 20:57:45 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
},
--- a/web/hdabo/templates/partial/list_for_orga.html Fri Jun 10 20:53:40 2011 +0200
+++ b/web/hdabo/templates/partial/list_for_orga.html Fri Jun 10 20:57:45 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();
--- a/web/hdabo/templates/partial/tag_table.html Fri Jun 10 20:53:40 2011 +0200
+++ b/web/hdabo/templates/partial/tag_table.html Fri Jun 10 20:57:45 2011 +0200
@@ -10,23 +10,28 @@
{% comment %}<th>original_label</th>{% endcomment %}
<th class="text_centered">Lien W</th>
<th>Facette</th>
- <th class="text_centered">Désactiver<br/>le lien W</th>
- <th class="text_centered">Supprimer<br/>le lien W</th>
+ <th class="large_25 text_centered">Lien W activé</th>
+ <th class="large_25 text_centered">Supprimer<br/>le lien W</th>
<th>Alias</th>
<th class="large_25 text_centered">Retirer le tag de la liste</th></tr>
{% if ordered_tags %}
{# ordered_tags is a list of TaggedSheet #}
{% for t in ordered_tags %}
<tr class="imageline {% cycle 'hdabooddline' 'hdaboevenline' %}">
- <td>{{forloop.counter}}-{{t.order}}</td>
+ <td>{{forloop.counter}}</td>
{% if valid != "2" %}
<td class="updown_td">{% if not forloop.first %}<img src="{{STATIC_URL}}hdabo/img/arrow_up.png" class="up" alt="up" id={{t.tag.id}} pos="{{forloop.counter0}}">{% endif %}</td>
<td class="updown_td">{% if not forloop.last %}<img src="{{STATIC_URL}}hdabo/img/arrow_down.png" class="down" alt="down" id={{t.tag.id}} pos="{{forloop.counter0}}">{% endif %}</td>
{% endif %}
<td>{{t.tag.id}}</td>
- <td>{{t.tag.label}}</td>
+ <td class="{{t.tag.url_status_text}}">{{t.tag.label}}</td>
{% comment %}<td>{{t.tag.original_label}}</td>{% endcomment %}
- <td class="text_centered"><a href="{% if t.tag.wikipedia_url %}{{t.tag.wikipedia_url}}{% else %}#{% endif %}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/arrow_right.png" ></a></td>
+ <td class="text_centered">
+ {% if t.tag.wikipedia_url and t.tag.wikipedia_url != "" %}
+ <a href="{{t.tag.wikipedia_url}}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/arrow_right.png" ></a>
+ {% else %}
+ <a href="http://fr.wikipedia.org/w/index.php?search={{t.tag.label}}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/wikipedia_search.png" ></a>
+ {% endif %}</td>
<td><select name="facette">
<option value="" selected></option>
<option value="datation">Datation</option>
@@ -35,7 +40,7 @@
<option value="ecole">Ecole/Mouvement</option>
<option value="discipline">Discipline artistique</option>
</select></td>
- <td class="text_centered"><input type="checkbox" class="activate_wp_cb" id={{t.tag.id}} {% if t.tag.wikipedia_activated %}checked{% endif %}/></td>
+ <td class="text_centered"><input type="checkbox" class="activate_wp_cb" id="{{t.tag.id}}" alt="{{t.tag.label}}" {% if t.tag.wikipedia_activated %}checked{% endif %} /></td>
<td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/red_cross.png" class="remove_wp_link" id="{{t.tag.id}}" /></td>
<td>{{t.tag.alias}}</td>
<td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/tag_remove.png" class="remove_tag_from_list" id="{{t.tag.id}}" alt="{{t.tag.label}}" /></td></tr>
@@ -50,13 +55,18 @@
<td class="updown_td">{% if not forloop.last %}<img src="{{STATIC_URL}}hdabo/img/arrow_down.png" class="down" alt="down" id="{{t.id}}" pos="{{forloop.counter0}}">{% endif %}</td>
{% endif %}
<td>{{t.id}}</td>
- <td>{{t.label}}</td>
+ <td class="{{t.url_status_text}}">{{t.label}}</td>
{% comment %}<td>{{t.original_label}}</td>{% endcomment %}
- <td class="text_centered"><a href="{% if t.wikipedia_url %}{{t.wikipedia_url}}{% else %}#{% endif %}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/arrow_right.png" ></a></td>
+ <td class="text_centered">
+ {% if t.wikipedia_url and t.wikipedia_url != "" %}
+ <a href="{{t.wikipedia_url}}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/arrow_right.png" ></a>
+ {% else %}
+ <a href="http://fr.wikipedia.org/w/index.php?search={{t.label}}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/wikipedia_search.png" ></a>
+ {% endif %}</td>
<td>facette</td>
- <td class="text_centered"><input type="checkbox" class="activate_wp_cb" id="{{t.id}}" {% if t.tag.wikipedia_activated %}checked{% endif %} /></td>
+ <td class="text_centered"><input type="checkbox" class="activate_wp_cb" id="{{t.id}}" {% if t.wikipedia_activated %}checked{% endif %} /></td>
<td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/red_cross.png" class="remove_wp_link" id="{{t.id}}" /></td>
- <td>{{t.tag.alias}}</td>
+ <td>{{t.alias}}</td>
<td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/tag_remove.png" class="remove_tag_from_list" id="{{t.id}}" alt="{{t.label}}" /></td></tr>
{% endfor %}
{% endif %}
--- a/web/hdabo/urls.py Fri Jun 10 20:53:40 2011 +0200
+++ b/web/hdabo/urls.py Fri Jun 10 20:57:45 2011 +0200
@@ -22,4 +22,5 @@
url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/(?P<length>[\w-]+)/$', 'hdabo.views.list_for_orga'),
url(r'^tagupdown$', 'hdabo.views.TagUpDown'),
url(r'^removetagfromlist$', 'hdabo.views.RemoveTagFromList'),
+ url(r'^validatelink$', 'hdabo.views.ValidateWPLink'),
)
--- a/web/hdabo/views.py Fri Jun 10 20:53:40 2011 +0200
+++ b/web/hdabo/views.py Fri Jun 10 20:57:45 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)