src/cm/views/texts.py
changeset 480 b9b802261109
parent 457 f62f7f0bcaa4
child 481 9e7de08fad32
--- 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)