--- a/web/hdabo/static/hdabo/css/style.css Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/static/hdabo/css/style.css Thu Jun 16 13:19:45 2011 +0200
@@ -361,6 +361,10 @@
.text_centered {
text-align: center;
}
+.hand_cursor, .reset_wp_info, .updown_td, .remove_wp_link, .remove_tag_from_list {
+ cursor: pointer;
+}
+
/* styles for the 4 types of STATUS*/
.null_result {
--- a/web/hdabo/static/hdabo/js/hdabo.js Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/static/hdabo/js/hdabo.js Thu Jun 16 13:19:45 2011 +0200
@@ -40,50 +40,13 @@
}
});
- $("#wp_search").autocomplete({
- source: function( request, response ) {
- $.ajax({
- url: "http://fr.wikipedia.org/w/api.php",
- dataType: "jsonp",
- data: {
- action: "opensearch",
- limit: "20",
- namespace: "0",
- format: "json",
- search: request.term
- },
- success: function( data ) {
- response( $.map( data[1], function( item ) {
- return {
- label: item,
- value: item
- }
- }));
- }
- });
- },
- minLength: 2,
- open: function() {
- $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
- },
- close: function() {
- $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
- }
- });
-
- $("#ok_search").click(function(){
- if($("#wp_search").val()!=""){
- add_tag($("#wp_search").val());
- }
- });
-
+ // Wikipedia search management (autocompletion and save changes)
$.editable.addInputType('autocomplete', {
element : $.editable.types.text.element,
plugin : function(settings, original) {
$('input', this).autocomplete(settings.autocomplete);
}
});
-
$(".wikipediatag").editable(modify_tag_url, {
indicator : "<img src='"+static_url+"hdabo/img/indicator.gif'>",
type : "autocomplete",
@@ -127,10 +90,89 @@
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
- }
+ }
}
});
+ // Update alias management
+ $(".tag_alias").editable(update_tag_alias_url, {
+ indicator : "<img src='"+static_url+"hdabo/img/indicator.gif'>",
+ type : "text",
+ placeholder:"",
+ tooltip : "Cliquer pour éditer...",
+ onblur : "submit",
+ submitdata: {
+ csrfmiddlewaretoken:global_csrf_token,
+ datasheet_id:$('#datasheet_id').val(),
+ num_page:$('#num_page').val(),
+ nb_by_page:$('#nb_by_page').val()
+ },
+ callback : function(value, settings) {
+ $('#tag_table_container').html(value);
+ init_tags_events();
+ }
+ });
+}
+
+function init_datasheet_events()
+{
+ // Wikipedia search management (new tag)
+ $("#wp_search").autocomplete({
+ source: function( request, response ) {
+ $.ajax({
+ url: "http://fr.wikipedia.org/w/api.php",
+ dataType: "jsonp",
+ data: {
+ action: "opensearch",
+ limit: "20",
+ namespace: "0",
+ format: "json",
+ search: request.term
+ },
+ success: function( data ) {
+ response( $.map( data[1], function( item ) {
+ return {
+ label: item,
+ value: item
+ }
+ }));
+ }
+ });
+ },
+ minLength: 2,
+ open: function() {
+ $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
+ },
+ close: function() {
+ $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
+ }
+ });
+ $("#ok_search").click(function(){
+ if($("#wp_search").val()!=""){
+ add_tag($("#wp_search").val());
+ }
+ });
+
+ // Validate sheet management : the radiobutton name has is "'gr_validated' + datasheet.hda_id"
+ $("#validated").click(function(e){
+ e.preventDefault();
+ // We count the number of tags. It has to be between 5 and 25
+ var nb_tags = $('#tag_table tr').length - 1;
+ if(nb_tags<5 || nb_tags>25){
+ alert("Cette fiche n'est pas validable : elle doit contenir entre 5 et 25 tags.");
+ }
+ else{
+ if(confirm("Confirmez-vous la validation de cette fiche ? Elle contient " + nb_tags + " tags.")){
+ window.location = validate_datasheet_url + "/" + $('#datasheet_id').val() + "/true";
+ }
+ }
+ });
+ $("#not_validated").click(function(e){
+ e.preventDefault();
+ if(confirm("Confirmez-vous l'invalidation de cette fiche ?")){
+ window.location = validate_datasheet_url + "/" + $('#datasheet_id').val() + "/false";
+ }
+ });
}
function update_tag(btn)
--- a/web/hdabo/templates/all_tags.html Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/templates/all_tags.html Thu Jun 16 13:19:45 2011 +0200
@@ -9,7 +9,6 @@
{% block js_declaration %}
{{block.super}}
- {% if valid != "2" %}
<script type="text/javascript">
var global_csrf_token = "{{ csrf_token }}";
@@ -21,12 +20,12 @@
var reset_wp_info_url = "{% url hdabo.views.reset_wikipedia_info %}";
var add_tag_url = "{% url hdabo.views.add_tag %}";
var remove_wp_link_url = "{% url hdabo.views.remove_wp_link %}";
+ var update_tag_alias_url = "{% url hdabo.views.update_tag_alias %}";
$(document).ready(function(){
init_tags_events();
});
</script>
- {% endif %}
{% endblock %}
{% block css_import %}
@@ -65,10 +64,10 @@
{% include "partial/all_tags_table.html" %}
</div>
<div id="count_nav_bottom">
- <p><a href="{% url hdabo.views.all_tags %}"><<</a>
- <a href="{% url hdabo.views.all_tags %}"><</a>
- bli/bla
- <a href="{% url hdabo.views.all_tags %}">></a>
- <a href="{% url hdabo.views.all_tags %}">>></a></p>
+ <p><a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page %}"><</a>
+ {{ num_page }}/{{ last_page }}
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page %}">>></a></p>
</div>
{% endblock %}
--- a/web/hdabo/templates/list_for_orga.html Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/templates/list_for_orga.html Thu Jun 16 13:19:45 2011 +0200
@@ -21,9 +21,12 @@
var reset_wp_info_url = "{% url hdabo.views.reset_wikipedia_info %}";
var add_tag_url = "{% url hdabo.views.add_tag %}";
var remove_wp_link_url = "{% url hdabo.views.remove_wp_link %}";
+ var validate_datasheet_url = "{% url hdabo.views.validate_datasheet %}";
+ var update_tag_alias_url = "{% url hdabo.views.update_tag_alias %}";
$(document).ready(function(){
init_tags_events();
+ init_datasheet_events();
});
</script>
{% endif %}
@@ -51,7 +54,8 @@
{% block content %}
{{block.super}}
- <p>Fiche(s) pour l'organisation <b>{{ orga_name }}</b> : {{nb_sheets}} fiche(s)</p>
+ <p>Fiche(s) {% if valid == "1" %}<b>validées</b>{% else %}{% if valid != "2" %}<b>non validées</b>{% endif %}{% endif %}
+ pour l'organisation <b>{{ orga_name }}</b> : {{nb_sheets}} fiche(s)</p>
{% if valid != "2" %}
<div id="count_nav_top">
<p><a href="{% url hdabo.views.list_for_orga orga_id=orga_id, valid=valid, start_index=0 %}"><<</a>
--- a/web/hdabo/templates/partial/all_tags_table.html Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/templates/partial/all_tags_table.html Thu Jun 16 13:19:45 2011 +0200
@@ -29,7 +29,7 @@
</select></td>
<td class="text_centered"><input type="checkbox" class="activate_wp_cb" id="{{tag.id}}" alt="{{tag.label}}" {% if tag.wikipedia_activated %}checked{% endif %} /></td>
<td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/red_cross.png" class="remove_wp_link" id="{{tag.id}}" alt="{{tag.label}}" /></td>
- <td>{{tag.alias}}</td></tr>
+ <td class="tag_alias" id="{{tag.id}}" >{% if tag.alias %}{{tag.alias}}{% endif %}</td></tr>
{% endfor %}
</table>
{% endblock %}
--- a/web/hdabo/templates/partial/one_sheet.html Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/templates/partial/one_sheet.html Thu Jun 16 13:19:45 2011 +0200
@@ -19,14 +19,13 @@
{# <p><b>original_modification_date</b><br/>{{ds.original_modification_date|date:"d/m/Y"}}</p> #}
</div>
<div class="right_sheet">
- <p><input type="radio" name="gr_validated{{ds.hda_id}}" value="not_validated" {% if not ds.validated %}checked{% endif %} />En cours
- <input type="radio" name="gr_validated{{ds.hda_id}}" value="validated" {% if ds.validated %}checked{% endif %} />Validé
+ <p><input type="radio" name="gr_validated{{ds.hda_id}}" id="not_validated" value="not_validated" {% if not ds.validated %}checked{% endif %} />En cours
+ <input type="radio" name="gr_validated{{ds.hda_id}}" id="validated" value="validated" {% if ds.validated %}checked{% endif %} />Validé
{% if ds.validated %}
- par : <input type="text" name="validator" value="{{ds.validated}}"/>
- le {{ds.validation_date}}
+ par {{ds.validator}} le {{ds.validation_date|date:"d/m/Y"}}
{% endif %}
{% if valid != "2" %}
- <span style="float:right;">Ajouter un tag : <input type="text" name="wp_search" id="wp_search" /><span id="ok_search" /><b>OK</b></span></span>
+ <span style="float:right;">Ajouter un tag : <input type="text" name="wp_search" id="wp_search" /> <span id="ok_search" class="hand_cursor"/><b>OK</b></span></span>
{% endif %}
</p>
{% csrf_token %}
--- a/web/hdabo/templates/partial/tag_table.html Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/templates/partial/tag_table.html Thu Jun 16 13:19:45 2011 +0200
@@ -42,7 +42,7 @@
</select></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}}" alt="{{t.tag.label}}" /></td>
- <td>{{t.tag.alias}}</td>
+ <td class="tag_alias" id="{{t.tag.id}}" >{% if t.tag.alias %}{{t.tag.alias}}{% endif %}</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>
{% endfor %}
{% else %}
--- a/web/hdabo/urls.py Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/urls.py Thu Jun 16 13:19:45 2011 +0200
@@ -16,13 +16,13 @@
url(r'^admin/', include(admin.site.urls)),
url(r'^search/', include('haystack.urls')),
url(r'^$', 'hdabo.views.home', name='home'),
- url(r'^list/(?P<orga_id>[\w-]+)$', 'hdabo.views.list_for_orga'),
- url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/$', 'hdabo.views.list_for_orga'),
- url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/$', 'hdabo.views.list_for_orga'),
- url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/(?P<length>[\w-]+)/$', 'hdabo.views.list_for_orga'),
+ url(r'^list/(?P<orga_id>[\w-]+)$', 'hdabo.views.list_for_orga', name='list_for_orga'),
+ url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'),
+ url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'),
+ url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/(?P<length>[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'),
url(r'^tagupdown$', 'hdabo.views.tag_up_down'),
url(r'^removetagfromlist$', 'hdabo.views.remove_tag_from_list'),
- url(r'^validatelink$', 'hdabo.views.validate_wp_link'),
+ url(r'^validatewplink$', 'hdabo.views.validate_wp_link'),
url(r'^modifytag$', 'hdabo.views.modify_tag'),
url(r'^resetwpinfo$', 'hdabo.views.reset_wikipedia_info'),
url(r'^addtag$', 'hdabo.views.add_tag'),
@@ -30,4 +30,8 @@
url(r'^alltags$', 'hdabo.views.all_tags'),
url(r'^alltags/(?P<num_page>[\w-]+)$', 'hdabo.views.all_tags'),
url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/$', 'hdabo.views.all_tags'),
+ url(r'^validatedatasheet$', 'hdabo.views.validate_datasheet'),
+ url(r'^validatedatasheet/(?P<ds_id>[\w-]+)$', 'hdabo.views.validate_datasheet'),
+ url(r'^validatedatasheet/(?P<ds_id>[\w-]+)/(?P<valid>[\w-]+)/$', 'hdabo.views.validate_datasheet'),
+ url(r'^updatetagalias$', 'hdabo.views.update_tag_alias'),
)
--- a/web/hdabo/views.py Thu Jun 16 13:19:07 2011 +0200
+++ b/web/hdabo/views.py Thu Jun 16 13:19:45 2011 +0200
@@ -2,7 +2,7 @@
from django.contrib.auth.decorators import login_required #@UnusedImport
from django.core.paginator import Paginator
from django.db.models import Max
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from hdabo.management.commands.querywikipedia import process_tag
from hdabo.wp_utils import normalize_tag, query_wikipedia_title
@@ -53,6 +53,7 @@
# And select the current one
datasheets = [datasheets[start_index]]
elif valid != "2":
+ valid = "0"
# We count all the validated sheets
datasheets = Datasheet.objects.filter(organisation=orga).filter(validated=False)
nb_sheets = len(datasheets)
@@ -273,7 +274,7 @@
tag.wikipedia_url = None
tag.wikipedia_pageid = None
tag.wikipedia_activated = False
-
+
process_tag(site, tag, 0)
if u"datasheet_id" in request.POST :
@@ -337,3 +338,50 @@
return get_tag_table(request=request, ds_id=request.POST["datasheet_id"], valid=0)
else :
return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"])
+
+
+#@login_required
+def validate_datasheet(request=None, ds_id=None, valid=None):
+ # We set if valid is true of false, function of the url parameters
+ if valid == "1" or valid == "true" or not valid :
+ valid = True
+ else :
+ valid = False
+ # We validate or unvalidate the requester datasheet
+ ds = Datasheet.objects.get(id=ds_id)
+ if valid :
+ ds.validate(None)
+ else :
+ ds.unvalidate()
+ ds.save()
+ # If there are still some unvalidated/validated ds for the ds's orga, we display the first one
+ same_organisation_ds = Datasheet.objects.filter(organisation=ds.organisation).filter(validated=not valid)
+ if valid :
+ # We ask to display the unvalidated ds
+ valid_req = 0
+ else :
+ # We ask to display the validated ds
+ valid_req = 1
+ if len(same_organisation_ds)>0 :
+ return redirect('list_for_orga', orga_id=ds.organisation.id, valid=valid_req)
+ else :
+ return redirect('home')
+
+
+#@login_required
+def update_tag_alias(request):
+ # 2 cases :
+ # - ordered tag for one datasheet : POST["datasheet_id"] is not null
+ # - all tags list : POST["datasheet_id"] is null and POST["num_page"] and POST["nb_by_page"] are not null
+ tag_id = request.POST["id"]
+ tag_alias = request.POST["value"]
+ tag = Tag.objects.get(id=tag_id)
+ tag.alias = tag_alias
+ tag.save()
+
+ if u"datasheet_id" in request.POST :
+ return get_tag_table(request=request, ds_id=request.POST["datasheet_id"], valid=0)
+ else :
+ return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"])
+
+
\ No newline at end of file