allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hei...@apache.org
Subject [01/29] allura git commit: [#8020] ticket:874 added filter to discussion moderation; added test for filtering [Forced Update!]
Date Wed, 27 Jan 2016 21:39:03 GMT
Repository: allura
Updated Branches:
  refs/heads/hs/8046 0bfa491ed -> 45f53f866 (forced update)


[#8020] ticket:874 added filter to discussion moderation; added test for filtering


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

Branch: refs/heads/hs/8046
Commit: 070769498ae13e9563676462dafc5b0b7ae91483
Parents: 2dd2ff0
Author: DeV1doR <dev1dor@ukr.net>
Authored: Wed Dec 9 20:27:29 2015 +0200
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Wed Jan 27 12:03:17 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py            |  7 +++++-
 Allura/allura/lib/widgets/discuss.py            |  2 ++
 .../allura/templates/discussion/moderate.html   |  2 +-
 .../tests/functional/test_forum.py              | 25 ++++++++++++++++++++
 4 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/07076949/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index c22e772..9812a98 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -35,6 +35,7 @@ from allura.lib.decorators import require_post
 from allura.lib.security import require_access
 
 from allura.lib.widgets import discuss as DW
+from allura.model.auth import User
 from .attachments import AttachmentsController, AttachmentController
 from .feed import FeedArgs, FeedController
 
@@ -427,6 +428,7 @@ class ModerationController(BaseController):
         page = kw.pop('page', 0)
         limit = kw.pop('limit', 50)
         status = kw.pop('status', 'pending')
+        username = kw.pop('username', None)
         flag = kw.pop('flag', None)
         c.post_filter = WidgetConfig.post_filter
         c.moderate_posts = WidgetConfig.moderate_posts
@@ -437,6 +439,9 @@ class ModerationController(BaseController):
             query['status'] = status
         if flag:
             query['flags'] = {'$gte': int(flag)}
+        if username:
+            filtered_user = User.query.get(username=username)
+            query['author_id'] = getattr(filtered_user, '_id', None)
         q = self.PostModel.query.find(query)
         count = q.count()
         limit, page, start = g.handle_paging(limit, page or 0, default=50)
@@ -446,7 +451,7 @@ class ModerationController(BaseController):
         pages = (count // limit) + 1
         return dict(discussion=self.discussion,
                     posts=q, page=page, limit=limit,
-                    status=status, flag=flag,
+                    status=status, flag=flag, username=username,
                     pgnum=pgnum, pages=pages)
 
     @h.vardec

http://git-wip-us.apache.org/repos/asf/allura/blob/07076949/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index e5ab85c..9d0955f 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -123,6 +123,8 @@ class PostFilter(ff.ForgeForm):
                         label='Show posts with at least "n" flags',
                         css_class='text',
                         if_missing=0),
+            ew.InputField(name='username',
+                          label='Show post filtered by (username)'),
             ew.SubmitButton(label='Filter Posts')
         ])
     ]

http://git-wip-us.apache.org/repos/asf/allura/blob/07076949/Allura/allura/templates/discussion/moderate.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/discussion/moderate.html b/Allura/allura/templates/discussion/moderate.html
index b5f2e22..81f0c18 100644
--- a/Allura/allura/templates/discussion/moderate.html
+++ b/Allura/allura/templates/discussion/moderate.html
@@ -34,6 +34,6 @@ Moderation Queue
   <a href="?status={{status}}&amp;flag={{flag}}&amp;page={{page-limit}}">Previous
Page</a>
   <a href="?status={{status}}&amp;flag={{flag}}&amp;page={{page+limit}}">Next
Page</a>
 </div>
-{{c.post_filter.display(action=discussion.url()+'moderate', value=dict(status=status, flag=flag))}}
+{{c.post_filter.display(action=discussion.url()+'moderate', value=dict(status=status, flag=flag,
username=username))}}
 {{c.moderate_posts.display(value=dict(posts=posts), action=discussion.url()+'moderate/save_moderation')}}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/07076949/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 5c6a180..0fafe71 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -408,6 +408,31 @@ class TestForum(TestController):
             'delete': 'Delete Marked'})
         _check()
 
+    def test_user_filter(self):
+        username = 'test_username1'
+        r = self.app.get(
+            '/discussion/testforum/moderate?username=%s' % username)
+        input_field = r.html.fieldset.find('input', {'value': username})
+        assert input_field is not None
+
+        username = 341
+        r = self.app.get(
+            '/discussion/testforum/moderate?username=%s' % username)
+        input_field = r.html.fieldset.find('input', {'value': username})
+        assert input_field is not None
+
+        username = 123.43523
+        r = self.app.get(
+            '/discussion/testforum/moderate?username=%s' % username)
+        input_field = r.html.fieldset.find('input', {'value': username})
+        assert input_field is not None
+
+        username = None
+        r = self.app.get(
+            '/discussion/testforum/moderate?username=%s' % username)
+        input_field = r.html.fieldset.find('input', {'value': username})
+        assert input_field is None
+
     def test_posting(self):
         r = self.app.get('/discussion/create_topic/')
         f = r.html.find('form', {'action': '/p/test/discussion/save_new_topic'})


Mime
View raw message