allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] allura git commit: [#7232] Fixes moderation links to paginated artifacts, hides reply link to unapproved posts
Date Fri, 27 Jan 2017 15:50:58 GMT
Repository: allura
Updated Branches:
  refs/heads/master d6ed1a9c9 -> 7002ae405


[#7232] Fixes moderation links to paginated artifacts, hides reply link to unapproved posts


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

Branch: refs/heads/master
Commit: 7002ae40579e7ea9a6eacf79763f622de7092149
Parents: 0d169af
Author: Kenton Taylor <ktaylor@slashdotmedia.com>
Authored: Thu Jan 26 16:21:02 2017 +0000
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Jan 27 10:46:45 2017 -0500

----------------------------------------------------------------------
 .../templates/widgets/moderate_posts.html       |  5 +++--
 .../allura/templates/widgets/post_thread.html   |  2 +-
 .../allura/templates/widgets/post_widget.html   |  2 +-
 .../tests/functional/test_forum.py              | 21 ++++++++++++++++++++
 4 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7002ae40/Allura/allura/templates/widgets/moderate_posts.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/moderate_posts.html b/Allura/allura/templates/widgets/moderate_posts.html
index 0d40d44..de0132a 100644
--- a/Allura/allura/templates/widgets/moderate_posts.html
+++ b/Allura/allura/templates/widgets/moderate_posts.html
@@ -54,8 +54,9 @@
           <td>{{post.attachments|length}}</td>
           <td>
           {% if c.app.config.tool_name.lower() != 'discussion' %}
-            {% if post and post.thread and post.thread.artifact %}
-              <a href="{{post.thread.artifact.url()}}#{{ post.slug }}">[{{post.thread.artifact.shorthand_id()}}]</a>
+          {% if post and post.thread and post.thread.artifact %}
+              {% set paginator = post.thread.artifact.url_paginated or post.thread.artifact.url
%}
+              <a href="{{ paginator() }}#{{ post.slug }}">[{{post.thread.artifact.shorthand_id()}}]</a>
             {% else %}
                 <!-- debug: missing pointers
                 {% if post %} post._id: {{ post._id }} {% endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/7002ae40/Allura/allura/templates/widgets/post_thread.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_thread.html b/Allura/allura/templates/widgets/post_thread.html
index f74c237..40bc774 100644
--- a/Allura/allura/templates/widgets/post_thread.html
+++ b/Allura/allura/templates/widgets/post_thread.html
@@ -24,7 +24,7 @@
     <!-- post_thread replies -->
     <ul>
       {%- if children %}
-      {%- for child in children if h.has_access(value, 'read') or child.post.status == 'ok'
%}
+      {%- for child in children %}
       {{widget.display(value=child.post, children=child.children, indent=indent+1)}}
       {%- endfor %}
       {%- endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/7002ae40/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 119134b..bb97234 100644
--- a/Allura/allura/templates/widgets/post_widget.html
+++ b/Allura/allura/templates/widgets/post_widget.html
@@ -57,7 +57,7 @@
             {{lib.user_link(value.author())}} - <i style="color: #777">{{lib.abbr_date(value.timestamp)}}</i>
 
             <div class="tools">
-            {% if h.has_access(value.thread, 'post')() %}
+            {% if (h.has_access(value.thread, 'post')() and value.status == 'ok') or moderator
%}
                 <a class="icon reply_post btn" href="#" style="" title="Reply" role="button"><span
class="ui-button-text"><i class="fa fa-reply"></i></span></a>
             {% endif %}
             <a href="{{shortlink_url}}" title="Shortlink" class="little_link shortlink
icon btn ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"{%if value.status
== 'pending'%} style="display:none"{%endif%}>

http://git-wip-us.apache.org/repos/asf/allura/blob/7002ae40/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 03296f8..a7d179e 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -516,6 +516,7 @@ class TestForum(TestController):
         thread = self.app.post('/discussion/save_new_topic', params=params,
                                extra_environ=dict(username='*anonymous')).follow()
 
+        # assert post awaiting moderation
         r = self.app.get(thread.request.url,
                          extra_environ=dict(username='*anonymous'))
         assert 'Post awaiting moderation' in r
@@ -523,6 +524,21 @@ class TestForum(TestController):
         assert 'name="approve"' not in r
         assert 'name="spam"' not in r
 
+        # assert unapproved thread replies do not appear
+        f = thread.html.find('div', {'class': 'row reply_post_form'}).find('form')
+        rep_url = f.get('action')
+        params = dict()
+        inputs = f.findAll('input')
+        for field in inputs:
+            if field.has_key('name'):  # nopep8 - beautifulsoup3 actually uses has_key
+                params[field['name']] = field.get('value') or ''
+        params[f.find('textarea')['name']] = 'anon reply to anon post content'
+        r = self.app.post(str(rep_url), params=params, extra_environ=dict(username='*anonymous'))
+        r = self.app.get(thread.request.url,
+                         extra_environ=dict(username='*anonymous'))
+        assert 'anon reply to anon post' not in r
+
+        # assert moderation controls appear for admin
         r = self.app.get(thread.request.url)
         assert '<div class="display_post moderate">' in r
         assert '<i class="fa fa-reply"></i>' in r
@@ -531,10 +547,15 @@ class TestForum(TestController):
         assert 'name="approve"' in r
         assert 'name="spam"' in r
         assert 'Post content' in r
+
+        # assert anon posts appear in moderation queue
         r = self.app.get('/discussion/testforum/moderate/')
         post = FM.ForumPost.query.get(text='Post content')
+        post2 = FM.ForumPost.query.get(text='anon reply to anon post content')
         link = '<a href="%s">[%s]</a>' % (post.thread.url() + '?limit=25#' +
post.slug, post.shorthand_id())
         assert link in r, link
+        link = '<a href="%s">[%s]</a>' % (post2.thread.url() + '?limit=25#' +
post2.slug, post2.shorthand_id())
+        assert link in r, link
 
     @td.with_tool('test2', 'Discussion', 'discussion')
     @mock.patch('allura.model.discuss.g.spam_checker')


Mime
View raw message