allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [2/7] allura git commit: [#8020] ticket:875 updated jquery for render; updated logic with undo; updated test
Date Thu, 24 Dec 2015 14:33:55 GMT
[#8020] ticket:875 updated jquery for render; updated logic with undo; updated test


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/2de3fc44
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2de3fc44
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2de3fc44

Branch: refs/heads/ib/8020a
Commit: 2de3fc44717070fae4c1a8344b4f15add6310f4f
Parents: b000761
Author: DeV1doR <dev1dor@ukr.net>
Authored: Sat Dec 12 17:18:08 2015 +0200
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Dec 23 12:48:00 2015 +0200

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py            |  4 +++-
 Allura/allura/lib/widgets/discuss.py            | 24 ++++++++++++++++----
 .../allura/templates/widgets/post_widget.html   |  1 +
 Allura/allura/tests/functional/test_discuss.py  |  9 +++++++-
 4 files changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2de3fc44/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index add5ef3..40320ee 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -356,7 +356,9 @@ class PostController(BaseController):
         elif kw.pop('spam', None):
             self.post.spam()
         elif kw.pop('undo', None):
-            self.post.status = 'pending'
+            prev_status = kw.pop('prev_status', None)
+            if prev_status:
+                self.post.status = prev_status
         elif kw.pop('approve', None):
             if self.post.status != 'ok':
                 self.post.approve()

http://git-wip-us.apache.org/repos/asf/allura/blob/2de3fc44/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 2d4dfea..ac4722d 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -342,23 +342,37 @@ class Post(HierWidget):
                             }
                             else if (mod == 'Spam'){
                                 spam_block_display($(post), 'none');
-                                $(post).find('.spam-present').show();
                             }
                             else if (mod == 'Undo'){
                                 spam_block_display($(post), 'block');
-                                $(post).find('.spam-present').hide();
-                                $(post).find('.options a').eq(0).hide();
                             }
                         }
                     });
                 });
 
                 function spam_block_display($post, display_type) {
-                    $post.find('.display_post').css(
-                        'display', display_type);
+                    var post_block = $post.find('.display_post');
+                    post_block.css('display', display_type);
+
+                    var attach_block = $post.find('.add_attachment_form').next();
+                    if (attach_block.attr('class') == undefined) {
+                        attach_block.css('display', display_type);
+                    }
+
                     $.each($post.find('.options').children(), function() {
                         $(this).css('display', display_type);
+                        if (
+                            $(this).hasClass('reply_post') &&
+                            $post.find('input[name="prev_status"]').attr('value') == 'pending'
+                        ) {
+                            $(this).hide();
+                        }
                     });
+                    if (display_type == 'none') {
+                        $post.find('.spam-present').show();
+                    } else {
+                        $post.find('.spam-present').hide();
+                    }
                 }
 
                 function get_cm($elem) { return $('.CodeMirror', $elem)[0].CodeMirror; }

http://git-wip-us.apache.org/repos/asf/allura/blob/2de3fc44/Allura/allura/templates/widgets/post_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_widget.html b/Allura/allura/templates/widgets/post_widget.html
index fa30770..016da48 100644
--- a/Allura/allura/templates/widgets/post_widget.html
+++ b/Allura/allura/templates/widgets/post_widget.html
@@ -49,6 +49,7 @@
           {% if h.has_access(value, 'moderate')() %}
           <form method="POST" action="{{value.url()+'moderate'}}">
             <input type="hidden" name="undo" value="True"/>
+            <input type="hidden" name="prev_status" value="{{value.status}}">
             <a href="" class="moderate_post little_link"><span>Undo</span></a>
             {{lib.csrf_token()}}
           </form>

http://git-wip-us.apache.org/repos/asf/allura/blob/2de3fc44/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 47218c8..719e57a 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -212,10 +212,17 @@ class TestDiscuss(TestDiscussBase):
         r = self._make_post('Test post')
         post_link = str(
             r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
-        self.app.post(post_link + 'moderate', params=dict(undo='undo'))
+
+        self.app.post(post_link + 'moderate', params=dict(
+            undo='undo', prev_status='pending'))
         post = M.Post.query.find().first()
         assert post.status == 'pending'
 
+        self.app.post(post_link + 'moderate', params=dict(
+            undo='undo', prev_status='ok'))
+        post = M.Post.query.find().first()
+        assert post.status == 'ok'
+
     @patch.object(M.Thread, 'is_spam')
     def test_feed_does_not_include_comments_held_for_moderation(self, is_spam):
         is_spam.return_value = True


Mime
View raw message