# HG changeset patch # User cavaliet # Date 1308148888 -7200 # Node ID 26368d096723ee18eada8e7547f2b8bf0971a8f2 # Parent ffd77b2b939fbd9e82e6b1c50e0d3138e218a3ef Datasheet validation, better repartition of js function, hand cursor on buttons. diff -r ffd77b2b939f -r 26368d096723 web/hdabo/static/hdabo/css/style.css --- a/web/hdabo/static/hdabo/css/style.css Tue Jun 14 18:26:52 2011 +0200 +++ b/web/hdabo/static/hdabo/css/style.css Wed Jun 15 16:41:28 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 ffd77b2b939f -r 26368d096723 web/hdabo/static/hdabo/js/hdabo.js --- a/web/hdabo/static/hdabo/js/hdabo.js Tue Jun 14 18:26:52 2011 +0200 +++ b/web/hdabo/static/hdabo/js/hdabo.js Wed Jun 15 16:41:28 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, save changes and new tag) $.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,70 @@ }, close: function() { $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); - } + } } }); +} + +function init_datasheet_events() +{ + // Wikipedia search management (autocompletion, save changes and 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 ffd77b2b939f -r 26368d096723 web/hdabo/templates/all_tags.html --- a/web/hdabo/templates/all_tags.html Tue Jun 14 18:26:52 2011 +0200 +++ b/web/hdabo/templates/all_tags.html Wed Jun 15 16:41:28 2011 +0200 @@ -65,10 +65,10 @@ {% include "partial/all_tags_table.html" %}
-

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

+

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

{% endblock %} diff -r ffd77b2b939f -r 26368d096723 web/hdabo/templates/list_for_orga.html --- a/web/hdabo/templates/list_for_orga.html Tue Jun 14 18:26:52 2011 +0200 +++ b/web/hdabo/templates/list_for_orga.html Wed Jun 15 16:41:28 2011 +0200 @@ -21,9 +21,11 @@ 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 %}"; $(document).ready(function(){ init_tags_events(); + init_datasheet_events(); }); {% endif %} @@ -51,7 +53,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 ffd77b2b939f -r 26368d096723 web/hdabo/templates/partial/one_sheet.html --- a/web/hdabo/templates/partial/one_sheet.html Tue Jun 14 18:26:52 2011 +0200 +++ b/web/hdabo/templates/partial/one_sheet.html Wed Jun 15 16:41:28 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 ffd77b2b939f -r 26368d096723 web/hdabo/urls.py --- a/web/hdabo/urls.py Tue Jun 14 18:26:52 2011 +0200 +++ b/web/hdabo/urls.py Wed Jun 15 16:41:28 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,7 @@ 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'), ) diff -r ffd77b2b939f -r 26368d096723 web/hdabo/views.py --- a/web/hdabo/views.py Tue Jun 14 18:26:52 2011 +0200 +++ b/web/hdabo/views.py Wed Jun 15 16:41:28 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) @@ -332,3 +333,33 @@ 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') + + \ No newline at end of file