allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/8] allura git commit: [#8020] ticket:874 added filter to discussion moderation; added test for filtering
Date Wed, 06 Jan 2016 19:30:20 GMT
Repository: allura
Updated Branches:
  refs/heads/db/8020 [created] 1159ede46


[#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/4479c27a
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/4479c27a
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/4479c27a

Branch: refs/heads/db/8020
Commit: 4479c27ac9a556503270967c131526371ba7368e
Parents: dfa249a
Author: DeV1doR <dev1dor@ukr.net>
Authored: Wed Dec 9 20:27:29 2015 +0200
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Wed Jan 6 12:51:40 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/4479c27a/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 4c0c748..13f3921 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
 
@@ -428,6 +429,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
@@ -438,6 +440,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)
@@ -447,7 +452,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/4479c27a/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 1e3d632..62adb16 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/4479c27a/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/4479c27a/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 7385357..a91b0c4 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