Replace pre_edit stage by an input checkbox to increase performances (compute_new_comment_positions run once).
authorgibus
Thu, 03 Jan 2013 11:42:46 +0100
changeset 480 b9b802261109
parent 479 49a1afacaea0
child 481 9e7de08fad32
Replace pre_edit stage by an input checkbox to increase performances (compute_new_comment_positions run once).
src/cm/locale/bg/LC_MESSAGES/django.mo
src/cm/locale/bg/LC_MESSAGES/django.po
src/cm/locale/en/LC_MESSAGES/django.po
src/cm/locale/es/LC_MESSAGES/django.mo
src/cm/locale/es/LC_MESSAGES/django.po
src/cm/locale/fr/LC_MESSAGES/django.mo
src/cm/locale/fr/LC_MESSAGES/django.po
src/cm/locale/it/LC_MESSAGES/django.mo
src/cm/locale/it/LC_MESSAGES/django.po
src/cm/locale/no/LC_MESSAGES/django.mo
src/cm/locale/no/LC_MESSAGES/django.po
src/cm/locale/pt_BR/LC_MESSAGES/django.mo
src/cm/locale/pt_BR/LC_MESSAGES/django.po
src/cm/media/js/site/text_edit.js
src/cm/templates/site/text_view_comments.html
src/cm/templates/site/text_view_frame.html
src/cm/views/texts.py
Binary file src/cm/locale/bg/LC_MESSAGES/django.mo has changed
--- a/src/cm/locale/bg/LC_MESSAGES/django.po	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/locale/bg/LC_MESSAGES/django.po	Thu Jan 03 11:42:46 2013 +0100
@@ -1903,6 +1903,16 @@
 msgid "Keep comments (if not affected by the edit)"
 msgstr "Запазете коментарите  (ако не са засегнати от редактирането)"
 
+#: views/texts.py:614
+#, fuzzy
+msgid "Detach comments (optional)"
+msgstr "Откъснете коментарите (по избор)"
+
+#: views/texts.py:617
+#, fuzzy
+msgid "If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked."
+msgstr "Ако някои коментари бяха прикрепени на chunck на текст, който се променя, проверете тази опция, за да се запазят тези коментари няма възможност. Оставете тази опция без отметка, ако искате, че такива коментари се заличават. Тази опция се игнорира, ако предишния 'Запазете коментарите' опция не е маркирана."
+
 #: views/texts.py:723
 msgid "Name (optional)"
 msgstr "Име (по избор)"
--- a/src/cm/locale/en/LC_MESSAGES/django.po	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/locale/en/LC_MESSAGES/django.po	Thu Jan 03 11:42:46 2013 +0100
@@ -1839,6 +1839,14 @@
 msgid "Keep comments (if not affected by the edit)"
 msgstr ""
 
+#: views/texts.py:614
+msgid "Detach comments (optional)"
+msgstr ""
+
+#: views/texts.py:617
+msgid "If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked."
+msgstr ""
+
 #: views/texts.py:723
 msgid "Name (optional)"
 msgstr ""
Binary file src/cm/locale/es/LC_MESSAGES/django.mo has changed
--- a/src/cm/locale/es/LC_MESSAGES/django.po	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/locale/es/LC_MESSAGES/django.po	Thu Jan 03 11:42:46 2013 +0100
@@ -1989,10 +1989,20 @@
 msgid "Keep comments (optional)"
 msgstr "Mantener los comentarios (opcional)"
 
-#: views/texts.py:657
+#: views/texts.py:617
 msgid "Keep comments (if not affected by the edit)"
 msgstr "Mantener los comentarios (si no son afectados por la edición)"
 
+#: views/texts.py:614
+#, fuzzy
+msgid "Detach comments (optional)"
+msgstr "Separe los comentarios (opcional)"
+
+#: views/texts.py:657
+#, fuzzy
+msgid "If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked."
+msgstr "Si algunos comentarios se adjunta a un chunck de texto que se modifica, marque esta opción para mantener estos comentarios sin alcance. Deje esta opción sin marcar si desea que esos comentarios serán eliminados. Esta opción se ignora si el anterior 'Mantener los comentarios' opción no está seleccionada."
+
 #: views/texts.py:723
 msgid "Name (optional)"
 msgstr "Nombre (opcional)"
Binary file src/cm/locale/fr/LC_MESSAGES/django.mo has changed
--- a/src/cm/locale/fr/LC_MESSAGES/django.po	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/locale/fr/LC_MESSAGES/django.po	Thu Jan 03 11:42:46 2013 +0100
@@ -1997,8 +1997,15 @@
 
 #: views/texts.py:657
 msgid "Keep comments (if not affected by the edit)"
-msgstr ""
-"Conserver les commentaires dont la portée n'a pas été affectée par l'édition"
+msgstr "Conserver les commentaires dont la portée n'a pas été affectée par l'édition"
+
+#: views/texts.py:614
+msgid "Detach comments (optional)"
+msgstr "Détacher les commentaires (facultatif)"
+
+#: views/texts.py:617
+msgid "If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked."
+msgstr "Si certains commentaires étaient attachés à une portion de texte qui a été modifiée, cochez cette option pour conserver ces commentaires sans portée. Laissez cette option décochée si vous souhaitez que ces commentaires soient supprimés. Cette option est ignorée si la précédente option 'Conserver les commentaires' n'est pas cochée."
 
 #: views/texts.py:723
 msgid "Name (optional)"
Binary file src/cm/locale/it/LC_MESSAGES/django.mo has changed
--- a/src/cm/locale/it/LC_MESSAGES/django.po	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/locale/it/LC_MESSAGES/django.po	Thu Jan 03 11:42:46 2013 +0100
@@ -2072,6 +2072,16 @@
 msgid "Keep comments (if not affected by the edit)"
 msgstr "Tieni i commenti (se non interessati dalle modifiche)"
 
+#: views/texts.py:614
+#, fuzzy
+msgid "Detach comments (optional)"
+msgstr "Staccare i commenti (opzionale)"
+
+#: views/texts.py:617
+#, fuzzy
+msgid "If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked."
+msgstr "Se alcuni commenti sono stati attaccati ad un chunck di testo che viene modificato, selezionare questa opzione per mantenere questi commenti senza ambito. Lasciate questa opzione deselezionata se si vuole che tali osservazioni è soppresso. Questa opzione viene ignorata se il precedente 'Tieni i commenti' opzione non è selezionata."
+
 #: views/texts.py:677
 msgid "Name (optional)"
 msgstr "Nome (opzionale)"
Binary file src/cm/locale/no/LC_MESSAGES/django.mo has changed
--- a/src/cm/locale/no/LC_MESSAGES/django.po	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/locale/no/LC_MESSAGES/django.po	Thu Jan 03 11:42:46 2013 +0100
@@ -1883,6 +1883,16 @@
 msgid "Keep comments (if not affected by the edit)"
 msgstr "Behold merknadene (dersom de ikke er påvirket av endringene i teksten)"
 
+#: views/texts.py:614
+#, fuzzy
+msgid "Detach comments (optional)"
+msgstr "Løsne merknader (valgfritt)"
+
+#: views/texts.py:617
+#, fuzzy
+msgid "If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked."
+msgstr "Hvis noen kommentarer var knyttet til en chunck av tekst som er endret, sjekk dette alternativet for å holde disse kommentarene uten omfang. La dette alternativet hvis du vil at slike kommentarer blir slettet. Dette alternativet blir ignorert hvis den forrige 'Behold merknader' alternativet er avmerket."
+
 #: views/texts.py:723
 msgid "Name (optional)"
 msgstr "Navn (valgfritt)"
Binary file src/cm/locale/pt_BR/LC_MESSAGES/django.mo has changed
--- a/src/cm/locale/pt_BR/LC_MESSAGES/django.po	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/locale/pt_BR/LC_MESSAGES/django.po	Thu Jan 03 11:42:46 2013 +0100
@@ -1892,6 +1892,16 @@
 msgid "Keep comments (if not affected by the edit)"
 msgstr "Manter comentários (se não afetados pela edição)"
 
+#: views/texts.py:614
+#, fuzzy
+msgid "Detach comments (optional)"
+msgstr "Retire comentários (opcional)"
+
+#: views/texts.py:617
+#, fuzzy
+msgid "If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked."
+msgstr "Se alguns comentários foram anexados a um chunck de texto que é modificado, marque esta opção para manter esses comentários sem escopo. Deixe essa opção desmarcada se desejar que esses comentários sejam excluídos. Esta opção é ignorada se o anterior 'Manter comentários' opção está desmarcada."
+
 #: views/texts.py:723
 msgid "Name (optional)"
 msgstr "Nome (opcional)"
--- a/src/cm/media/js/site/text_edit.js	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/media/js/site/text_edit.js	Thu Jan 03 11:42:46 2013 +0100
@@ -1,79 +1,22 @@
 function check_save(){
-    var newVersion = $('#id_new_version').attr('checked') ;
-    var commentsKept = $('#id_keep_comments').attr('checked') ;
-
-    var new_content = $('#id_content').val() ;
-    
-    var o=CKEDITOR.instances['id_content'];
-    if (o) new_content=o.getData();
-    
-    var new_format = $('#id_format').val() ;
-    var mess = gettext( 'Should these comments be detached (i.e. kept with no scope) or removed from new version?') ;
+  var newVersion = $('#id_new_version').attr('checked') ;
+  var commentsKept = $('#id_keep_comments').attr('checked') ;
 
-    if (commentsKept) {
-        var pre_edit_url = tb_conf['pre_edit_url'] ;
-        $.ajax({
-           url: pre_edit_url,
-           type:'POST',
-           dataType:"json",
-           data: { "new_content": new_content,  "new_format": new_format},
-           success: function(obj){
-               nb_removed = obj['nb_removed'];
-               if (newVersion) {
-                    if (nb_removed == 0) {
-                     submit_edit_form();
-                    }
-                    else {
-                    var message = ngettext( 
-                        '%(nb_comments)s comment applies to text that was modified.',
-                        '%(nb_comments)s comments apply to text that was modified.', 
-                nb_removed) ;
-                    message += '<br />' ;
-                    message += mess ;
-                    message = interpolate(message,{'nb_comments':nb_removed}, true) ;   
-                    
-                        $('#remove_scope_choice_dlg').html(message) ;
-                        $('#remove_scope_choice_dlg').dialog('open') ;
-                    }
-               }
-               else {                  
-                   if (nb_removed == 0) {
-                     submit_edit_form();
-                    }
-                   else {
-                    var message = ngettext(  
-                        '%(nb_comments)s comment applies to text that was modified.',
-                        '%(nb_comments)s comments apply to text that was modified.', 
-                nb_removed) ;
-                    message += '<br />' ;
-                    message += gettext( '(We suggest you create a new version)') ;
-                    message += '<br />' ;
-                    message += mess ;
-                    message = interpolate(message,{'nb_comments':nb_removed}, true) ;   
-
-                    $('#remove_scope_choice_dlg').html(message) ;
-                        $('#remove_scope_choice_dlg').dialog('open') ;
-                   }
-               }
-           },
-           error: function(msg){
-               alert("error: " + msg);
-           }
-        });
+  if (commentsKept) {
+    submit_edit_form();
+  }
+  else {
+    if (!newVersion) {
+      var message = gettext("You chose not to create a new version all comments will be deleted") ;
+      message += '<br />' ;
+      message += gettext( 'Do you want to continue?') ;
+      $('#confirm_all_removed_dlg').html(message) ;
+      $('#confirm_all_removed_dlg').dialog('open') ;
     }
     else {
-        if (!newVersion) {
-          
-            var message = gettext("You chose not to create a new version all comments will be deleted") ;
-        message += '<br />' ;
-        message += gettext( 'Do you want to continue?') ;
-            $('#confirm_all_removed_dlg').html(message) ;
-            $('#confirm_all_removed_dlg').dialog('open') ;
-        }
-        else {
-          submit_edit_form() ;        
-        }
+      submit_edit_form() ;        
     }
+  }
 }
 
 function submit_edit_form() {
@@ -90,26 +33,13 @@
     $(this).dialog('close');submit_edit_form();
   } ; 
 
-    $('#confirm_all_removed_dlg').dialog({
-        bgiframe: true, 
-        autoOpen: false,        
-        title :gettext('Warning'),
-        modal: true,
-        buttons:buttons
-    }) ;
-    
-  var buttons0 = {};
-  buttons0[gettext('Detach')] = function() {$(this).dialog('close');$('#cancel_modified_scopes').val("1");submit_edit_form();} ;
-  buttons0[gettext('Remove')] = function() {$(this).dialog('close');$('#cancel_modified_scopes').val("0");submit_edit_form();} ;
-  buttons0[gettext('Cancel')] = function() {$(this).dialog('close');} ;
+  $('#confirm_all_removed_dlg').dialog({
+    bgiframe: true, 
+    autoOpen: false,        
+    title :gettext('Warning'),
+    modal: true,
+    buttons:buttons
+  }) ;
 
-    $('#remove_scope_choice_dlg').dialog({
-        bgiframe: true, 
-        autoOpen: false,        
-        title :gettext('Warning'),
-        modal: true,
-        buttons:buttons0
-    }) ;
-
-    $("#save").click(function() { check_save() ;}) ;
+  $("#save").click(function() { check_save() ;}) ;
 }) ;
--- a/src/cm/templates/site/text_view_comments.html	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/templates/site/text_view_comments.html	Thu Jan 03 11:42:46 2013 +0100
@@ -110,7 +110,7 @@
 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/site/c_text_view_comments.js"></script> 
 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/lib/asciimathtml/ASCIIMathML.js"></script>
 {% else %}
-<script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/c_client-min.js?1354282884"></script> 
+<script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/c_client-min.js?1357209524"></script> 
 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/lib/asciimathtml/ASCIIMathML.min.js"></script>
 {% endif %}
 
--- a/src/cm/templates/site/text_view_frame.html	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/templates/site/text_view_frame.html	Thu Jan 03 11:42:46 2013 +0100
@@ -37,7 +37,7 @@
     <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/f_printDialog.js"></script>
     <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/site/f_text_view_frame.js"></script>
 {% else %}
-    <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/f_client-min.js?1354282884"></script> 
+    <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/f_client-min.js?1357209524"></script> 
 {% endif %}
     <style type="text/css">
         /*
--- a/src/cm/views/texts.py	Thu Jan 03 11:07:33 2013 +0100
+++ b/src/cm/views/texts.py	Thu Jan 03 11:42:46 2013 +0100
@@ -247,12 +247,12 @@
                                'text_version' : text_version,
                                'title' : text_version.title, # TODO use it ...
                                'get_params' : get_params,
-                               'json_comments':jsonize(comments, request),
-                               'json_filter_datas':jsonize(filter_datas, request),
                                'content' : wrapped_text_version,
                                'client_date_fmt' : settings.CLIENT_DATE_FMT,
                                'read_only' : read_only,
                                }
+    template_dict['json_comments'] = jsonize(comments, request)
+    template_dict['json_filter_datas'] = jsonize(filter_datas, request)
     return render_to_response('site/text_view_comments.html',
                               template_dict,
                               context_instance=RequestContext(request))
@@ -610,6 +610,12 @@
                            initial=True,
                            help_text=ugettext_lazy("Keep comments (if not affected by the edit)")
                            )
+
+    cancel_modified_scopes = forms.BooleanField(label=ugettext_lazy("Detach comments (optional)"),
+                           required=False,
+                           initial=True,
+                           help_text=ugettext_lazy("If some comments were attached to a chunck of text that is modified, check this option to keep these comments with no scope. Leave this option unchecked if you want that such comments be deleted. This option is ignored if the previous 'Keep comment' option is unchecked.")
+                           )
     
     class Meta:
         model = TextVersion
@@ -622,7 +628,7 @@
         new_note = request.POST.get('note',None)
         new_tags = request.POST.get('tags',None)
         keep_comments = bool(request.POST.get('keep_comments',None))
-        cancel_modified_scopes = (request.POST.get('cancel_modified_scopes',u'1') == u'1')
+        cancel_modified_scopes = bool(request.POST.get('cancel_modified_scopes',None))
         version = text.get_latest_version()
         version.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments, cancel_modified_scopes)
 
@@ -634,11 +640,11 @@
         new_format = request.POST.get('format', text.last_text_version.format)        
         new_note = request.POST.get('note',None)
         new_tags = request.POST.get('tags',None)
-        cancel_modified_scopes = (request.POST.get('cancel_modified_scopes',u'1') == u'1')
         
-        new_text_version = text.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments=True, cancel_modified_scopes=cancel_modified_scopes, new_version=True)
+        new_text_version = text.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments=True, cancel_modified_scopes=True, new_version=True)
 
         keep_comments = bool(request.POST.get('keep_comments',None))
+        cancel_modified_scopes = bool(request.POST.get('cancel_modified_scopes',None))
         new_text_version.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments, cancel_modified_scopes)
         new_text_version.user = request.user if request.user.is_authenticated() else None
         new_text_version.note = request.POST.get('note','')
@@ -709,6 +715,7 @@
                         'new_version': NEW_TEXT_VERSION_ON_EDIT,
                         'note' : '',
                         'keep_comments' : True,
+                        'cancel_modified_scopes' : True,
                        }        
         if request.user.is_authenticated():
             form = EditTextForm(default_data)