allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [05/10] allura git commit: [#8020] ticket:875 added test for undo; added text when spam clicking occured at ticket post page
Date Thu, 21 Jan 2016 15:29:44 GMT
[#8020] ticket:875 added test for undo; added text when spam clicking occured at ticket post
page


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

Branch: refs/heads/ib/8020b
Commit: 45c5cf28802da07c09ba9b65727ce968d6d63c55
Parents: 670afe6
Author: DeV1doR <dev1dor@ukr.net>
Authored: Fri Dec 11 13:56:05 2015 +0200
Committer: Denis Kotov <deniskkotov@gmail.com>
Committed: Wed Jan 20 16:03:45 2016 +0200

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py             |  2 ++
 Allura/allura/lib/widgets/discuss.py             | 17 +++++++++++++++--
 Allura/allura/nf/allura/css/site_style.css       |  6 ++++++
 Allura/allura/templates/widgets/post_widget.html | 12 +++++++++++-
 Allura/allura/tests/functional/test_discuss.py   |  8 ++++++++
 5 files changed, 42 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/45c5cf28/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 818cc10..add5ef3 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -355,6 +355,8 @@ class PostController(BaseController):
             self.post.delete()
         elif kw.pop('spam', None):
             self.post.spam()
+        elif kw.pop('undo', None):
+            self.post.status = 'pending'
         elif kw.pop('approve', None):
             if self.post.status != 'ok':
                 self.post.approve()

http://git-wip-us.apache.org/repos/asf/allura/blob/45c5cf28/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index a8e475d..6503d5b 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -339,13 +339,26 @@ class Post(HierWidget):
                                 $('a.reply_post, a.shortlink, form.moderate_spam, form.moderate_approve',
post).toggle();
                                 $('div.moderate', post).removeClass('moderate');
                             }
-                            else if (mod === 'Spam'){
-                                $(post).remove();
+                            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();
                             }
                         }
                     });
                 });
 
+                function spam_block_display($post, display_type) {
+                    $post.find('.display_post').css(
+                        'display', display_type);
+                    $.each($post.find('.options').children(), function() {
+                        $(this).css('display', display_type);
+                    });
+                }
+
                 function get_cm($elem) { return $('.CodeMirror', $elem)[0].CodeMirror; }
 
                 if($('a.edit_post', post)){

http://git-wip-us.apache.org/repos/asf/allura/blob/45c5cf28/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index c0ddbd0..5dd347d 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -3428,3 +3428,9 @@ fieldset.preferences legend {
 .ui-autocomplete {
   z-index: 10; /* so autocomplete of tags or username is always over markdown editor components
*/
 }
+.spam-present {
+  display: none;
+}
+.spam-text {
+  float: left;
+}

http://git-wip-us.apache.org/repos/asf/allura/blob/45c5cf28/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 096e829..a8aa822 100644
--- a/Allura/allura/templates/widgets/post_widget.html
+++ b/Allura/allura/templates/widgets/post_widget.html
@@ -43,7 +43,17 @@
       </div>
       {% set pending = value.status == 'pending' %}
       {% set moderator = h.has_access(value, 'moderator')() %}
-      <div class="grid-14" style="width: {{indent == 0 and 525 or (indent <= 40 and
515-indent*10 or 65)}}px">
+      <div class="grid-14 post-content" style="width: {{indent == 0 and 525 or (indent
<= 40 and 515-indent*10 or 65)}}px">
+        <div class="spam-present">
+          <span class="spam-text">Comment has been marked as spam.&nbsp;</span>
+          <form method="POST" action="{{value.url()+'moderate'}}">
+            <input type="hidden" name="undo" value="True"/>
+            <a href="" class="moderate_post little_link"><span>Undo</span></a>
+            {{lib.csrf_token()}}
+          </form>
+          <br>
+          <span class="spam-text">You can see all comments posted by this user&nbsp;</span><a
href="/p/test/tickets/_discuss/moderate">here</a>
+        </div>
         <div class="display_post{% if pending and moderator %} moderate{% endif %}">
           {% if pending and not moderator %}
             <b>Post awaiting moderation.</b>

http://git-wip-us.apache.org/repos/asf/allura/blob/45c5cf28/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 d70664b..47218c8 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -208,6 +208,14 @@ class TestDiscuss(TestDiscussBase):
             ))
         assert r_bad_filtered.html.tbody.findAll('tr') == []
 
+    def test_undo(self):
+        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'))
+        post = M.Post.query.find().first()
+        assert post.status == 'pending'
+
     @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