# HG changeset patch # User ymh # Date 1308223185 -7200 # Node ID e2d9295b126ba1effa939cfe0a94ba1de1e5dcf3 # Parent 85f45ad591f670224f1e6046aad3aff584861210# Parent 4e8129c9f858e1bc87d66db6bcda636775fa257f Merge with 4e8129c9f858e1bc87d66db6bcda636775fa257f diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/static/hdabo/css/style.css --- 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 { diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/static/hdabo/js/hdabo.js --- 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 : "", 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 : "", + 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) diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/templates/all_tags.html --- 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" %} - {% endif %} {% endblock %} {% block css_import %} @@ -65,10 +64,10 @@ {% include "partial/all_tags_table.html" %}
-

<<   - <   - bli/bla   - >   - >>

+

<<   + <   + {{ num_page }}/{{ last_page }}   + >   + >>

{% endblock %} diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/templates/list_for_orga.html --- 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(); }); {% endif %} @@ -51,7 +54,8 @@ {% block content %} {{block.super}} -

Fiche(s) pour l'organisation {{ orga_name }} : {{nb_sheets}} fiche(s)

+

Fiche(s) {% if valid == "1" %}validées{% else %}{% if valid != "2" %}non validées{% endif %}{% endif %} + pour l'organisation {{ orga_name }} : {{nb_sheets}} fiche(s)

{% if valid != "2" %}

<<   diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/templates/partial/all_tags_table.html --- 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 @@ {{tag.label}} - {{tag.alias}} + {% if tag.alias %}{{tag.alias}}{% endif %} {% endfor %} {% endblock %} diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/templates/partial/one_sheet.html --- 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 @@ {#

original_modification_date
{{ds.original_modification_date|date:"d/m/Y"}}

#}
-

En cours - Validé +

En cours + Validé {% if ds.validated %} -       par : -       le {{ds.validation_date}} +    par {{ds.validator}} le {{ds.validation_date|date:"d/m/Y"}} {% endif %} {% if valid != "2" %} - Ajouter un tag : OK + Ajouter un tag : OK {% endif %}

{% csrf_token %} diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/templates/partial/tag_table.html --- 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 @@ {{t.tag.label}} - {{t.tag.alias}} + {% if t.tag.alias %}{{t.tag.alias}}{% endif %} {{t.tag.label}} {% endfor %} {% else %} diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/urls.py --- 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[\w-]+)$', 'hdabo.views.list_for_orga'), - url(r'^list/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.list_for_orga'), - url(r'^list/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.list_for_orga'), - url(r'^list/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.list_for_orga'), + url(r'^list/(?P[\w-]+)$', 'hdabo.views.list_for_orga', name='list_for_orga'), + url(r'^list/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'), + url(r'^list/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.list_for_orga', name='list_for_orga'), + url(r'^list/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+)/(?P[\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[\w-]+)$', 'hdabo.views.all_tags'), url(r'^alltags/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.all_tags'), + url(r'^validatedatasheet$', 'hdabo.views.validate_datasheet'), + url(r'^validatedatasheet/(?P[\w-]+)$', 'hdabo.views.validate_datasheet'), + url(r'^validatedatasheet/(?P[\w-]+)/(?P[\w-]+)/$', 'hdabo.views.validate_datasheet'), + url(r'^updatetagalias$', 'hdabo.views.update_tag_alias'), ) diff -r 85f45ad591f6 -r e2d9295b126b web/hdabo/views.py --- 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