# HG changeset patch # User raph # Date 1280146581 -7200 # Node ID 6e8fb4869d509d0f11b2c202565d24e4e24d5bb1 # Parent 7aaf5c0d6af4a5060a4db83b510cd2f00f24a93b fix: use 'keep_comments' parameter when editing text diff -r 7aaf5c0d6af4 -r 6e8fb4869d50 src/cm/tests/test_comment_positioning.py --- a/src/cm/tests/test_comment_positioning.py Thu Jul 22 17:27:24 2010 +0200 +++ b/src/cm/tests/test_comment_positioning.py Mon Jul 26 14:16:21 2010 +0200 @@ -53,6 +53,23 @@ else: x, y , z, k = new self.assert_comment(id, x, y, z, k) + + def test_remove_comment(self): + content = u"""This is a test text""" + new_content = u"""This is a teeest text""" + + text = Text.objects.create_text("text", "html", content, "", "", "", None) + + comment1 = create_comment(2, 2, 2, 4) + comment2 = create_comment(2, 2, 2, 4) + + version = Text.objects.all()[0].get_latest_version() + + self.assertEqual(len(version.get_comments()), 2) + + version.edit("text", "html", new_content, keep_comments = False, cancel_modified_scopes=False) + + self.assertEqual(len(version.get_comments()), 0) def test_wrapper_shifted(self): content = u"""This is a test text""" diff -r 7aaf5c0d6af4 -r 6e8fb4869d50 src/cm/views/texts.py --- a/src/cm/views/texts.py Thu Jul 22 17:27:24 2010 +0200 +++ b/src/cm/views/texts.py Mon Jul 26 14:16:21 2010 +0200 @@ -666,9 +666,10 @@ 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) + keep_comments = bool(request.POST.get('keep_comments',None)) cancel_modified_scopes = (request.POST.get('cancel_modified_scopes',u'1') == u'1') version = text.get_latest_version() - version.edit(new_title, new_format, new_content, new_tags, new_note, True, cancel_modified_scopes) + version.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments, cancel_modified_scopes) return version @@ -681,8 +682,9 @@ 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.edit(new_title, new_format, new_content, new_tags, new_note, True, cancel_modified_scopes) + + keep_comments = bool(request.POST.get('keep_comments',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','') new_text_version.email = request.POST.get('email','')