# HG changeset patch # User cavaliet # Date 1308157242 -7200 # Node ID 4e8129c9f858e1bc87d66db6bcda636775fa257f # Parent a8b97ccf8b85938d19ce0e96810580701b1aeea1 Add alias update feature. diff -r a8b97ccf8b85 -r 4e8129c9f858 web/hdabo/static/hdabo/js/hdabo.js --- a/web/hdabo/static/hdabo/js/hdabo.js Wed Jun 15 16:43:39 2011 +0200 +++ b/web/hdabo/static/hdabo/js/hdabo.js Wed Jun 15 19:00:42 2011 +0200 @@ -40,7 +40,7 @@ } }); - // Wikipedia search management (autocompletion, save changes and new tag) + // Wikipedia search management (autocompletion and save changes) $.editable.addInputType('autocomplete', { element : $.editable.types.text.element, plugin : function(settings, original) { @@ -93,11 +93,30 @@ } } }); + + // 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 (autocompletion, save changes and new tag) + // Wikipedia search management (new tag) $("#wp_search").autocomplete({ source: function( request, response ) { $.ajax({ diff -r a8b97ccf8b85 -r 4e8129c9f858 web/hdabo/templates/all_tags.html --- a/web/hdabo/templates/all_tags.html Wed Jun 15 16:43:39 2011 +0200 +++ b/web/hdabo/templates/all_tags.html Wed Jun 15 19:00:42 2011 +0200 @@ -9,7 +9,6 @@ {% block js_declaration %} {{block.super}} - {% if valid != "2" %} - {% endif %} {% endblock %} {% block css_import %} diff -r a8b97ccf8b85 -r 4e8129c9f858 web/hdabo/templates/list_for_orga.html --- a/web/hdabo/templates/list_for_orga.html Wed Jun 15 16:43:39 2011 +0200 +++ b/web/hdabo/templates/list_for_orga.html Wed Jun 15 19:00:42 2011 +0200 @@ -22,6 +22,7 @@ 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(); diff -r a8b97ccf8b85 -r 4e8129c9f858 web/hdabo/templates/partial/all_tags_table.html --- a/web/hdabo/templates/partial/all_tags_table.html Wed Jun 15 16:43:39 2011 +0200 +++ b/web/hdabo/templates/partial/all_tags_table.html Wed Jun 15 19:00:42 2011 +0200 @@ -29,7 +29,7 @@ {{tag.label}} - {{tag.alias}} + {% if tag.alias %}{{tag.alias}}{% endif %} {% endfor %} {% endblock %} diff -r a8b97ccf8b85 -r 4e8129c9f858 web/hdabo/templates/partial/tag_table.html --- a/web/hdabo/templates/partial/tag_table.html Wed Jun 15 16:43:39 2011 +0200 +++ b/web/hdabo/templates/partial/tag_table.html Wed Jun 15 19:00:42 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 a8b97ccf8b85 -r 4e8129c9f858 web/hdabo/urls.py --- a/web/hdabo/urls.py Wed Jun 15 16:43:39 2011 +0200 +++ b/web/hdabo/urls.py Wed Jun 15 19:00:42 2011 +0200 @@ -33,4 +33,5 @@ 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 a8b97ccf8b85 -r 4e8129c9f858 web/hdabo/views.py --- a/web/hdabo/views.py Wed Jun 15 16:43:39 2011 +0200 +++ b/web/hdabo/views.py Wed Jun 15 19:00:42 2011 +0200 @@ -274,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 : @@ -367,4 +367,21 @@ else : return redirect('home') - \ No newline at end of file + +#@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