You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/11/17 23:04:22 UTC
allura git commit: [#7981] show appropriate items for anonymous users,
tighten up thread list display
Repository: allura
Updated Branches:
refs/heads/db/7981 [created] 3c0a49abf
[#7981] show appropriate items for anonymous users, tighten up thread list display
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/3c0a49ab
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/3c0a49ab
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/3c0a49ab
Branch: refs/heads/db/7981
Commit: 3c0a49abf62aa0946e88b2d00b121c0d0c42f86b
Parents: e40100b
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Nov 17 15:28:04 2016 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Nov 17 18:04:16 2016 -0500
----------------------------------------------------------------------
Allura/allura/lib/helpers.py | 2 +-
Allura/allura/lib/security.py | 8 ++++++++
Allura/allura/nf/allura/css/site_style.css | 3 +++
Allura/allura/templates/widgets/page_list.html | 17 ++++++++++-------
.../templates/widgets/subscription_form.html | 9 ++++++---
Allura/allura/templates/widgets/thread_widget.html | 10 +++++++---
Allura/allura/templates/widgets/threads_table.html | 16 +++++++++-------
.../templates/discussionforums/create_topic.html | 3 +++
.../templates/discussionforums/thread.html | 2 +-
9 files changed, 48 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index b90692a..181fdcd 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -64,7 +64,7 @@ from allura.lib import AsciiDammit
from allura.lib import utils
# import to make available to templates, don't delete:
-from .security import has_access
+from .security import has_access, is_allowed_by_role
log = logging.getLogger(__name__)
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/Allura/allura/lib/security.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/security.py b/Allura/allura/lib/security.py
index bd98c9a..41691f4 100644
--- a/Allura/allura/lib/security.py
+++ b/Allura/allura/lib/security.py
@@ -441,6 +441,14 @@ def all_allowed(obj, user_or_role=None, project=None):
return perms
+def is_allowed_by_role(obj, permission, role_name, project):
+ # probably more effecient ways of doing these, e.g. through a modified has_access
+ # but this is easy
+ from allura import model as M
+ role = M.ProjectRole.by_name(role_name, project)
+ return permission in all_allowed(obj, role, project)
+
+
def require(predicate, message=None):
'''
Example: ``require(has_access(c.app, 'read'))``
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/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 c114f94..a8c8673 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2593,6 +2593,9 @@ div.attachment_item{
.forum-list th .ico {
margin-left: 4px;
}
+.forum-list .topic h3 {
+ padding-left: 0;
+}
.gravatar b {
overflow: visible;
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/Allura/allura/templates/widgets/page_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/page_list.html b/Allura/allura/templates/widgets/page_list.html
index 64ff18f..2621601 100644
--- a/Allura/allura/templates/widgets/page_list.html
+++ b/Allura/allura/templates/widgets/page_list.html
@@ -16,12 +16,15 @@
specific language governing permissions and limitations
under the License.
-#}
+{% set pager_output = paginator.pager(
+ format='$link_first $link_previous ~2~ $link_next $link_last' + (show_label and ' (Page $page of $page_count)' or ''),
+ show_if_single_page=show_if_single_page
+ ) %}
+{% if pager_output.strip() %}
<div>
- <div class="page_list">
- {{paginator.pager(
- format='$link_first $link_previous ~2~ $link_next $link_last' + (show_label and ' (Page $page of $page_count)' or ''),
- show_if_single_page=show_if_single_page
- )}}
- </div>
- <div class="clear"></div>
+ <div class="page_list">
+ {{ pager_output }}
+ </div>
+ <div class="clear"></div>
</div>
+{% endif %}
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/Allura/allura/templates/widgets/subscription_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/subscription_form.html b/Allura/allura/templates/widgets/subscription_form.html
index 1a58efe..7b6ef2f 100644
--- a/Allura/allura/templates/widgets/subscription_form.html
+++ b/Allura/allura/templates/widgets/subscription_form.html
@@ -19,14 +19,17 @@
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
<div {{attrs|default({}, true)|xmlattr}} class="discussion_subscription_form">
<div class="clear"></div>
- <div class="pagination_size">{{widget.fields['page_list'].display(limit=limit, page=page, count=count)}}</div>
+ {% set pager_widget_output = widget.fields['page_list'].display(limit=limit, page=page, count=count) %}
+ {% if pager_widget_output.strip() %}
+ <div class="pagination_size">{{ pager_widget_output }}</div>
+ {% endif %}
<form method="{{method}}" action="{{action}}" {% if enctype %}enctype="{{enctype}}"{% endif %} class="follow_form">
{{widget.fields['threads'].display(value=threads)}}
+ {% if threads and not c.user.is_anonymous() %}
<p>
- {% if threads %}
<input type="submit" value="Update email subscriptions"/>
- {% endif %}
</p>
+ {% endif %}
{% if method.upper() == 'POST' %}{{lib.csrf_token()}}{% endif %}
</form>
{{widget.fields['page_list'].display(limit=limit, page=page, count=count)}}
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/Allura/allura/templates/widgets/thread_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/thread_widget.html b/Allura/allura/templates/widgets/thread_widget.html
index fa26fd7..f9a6d9d 100644
--- a/Allura/allura/templates/widgets/thread_widget.html
+++ b/Allura/allura/templates/widgets/thread_widget.html
@@ -19,8 +19,8 @@
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
<div>
- <div class="row">
- <div class="column grid_12">
+ <div class="row">
+ <div class="column grid_12">
{% if limit %}
{{widgets.page_list.display(limit=limit, page=page, count=count)}}
{% endif %}
@@ -68,5 +68,9 @@
</div>
</div>
</div>
-
+{% elif c.user.is_anonymous() and h.is_allowed_by_role(value, 'post', '*authenticated', c.project)%}
+ <hr>
+ <p>
+ <a href="{{ tg.config.get('auth.login_url', '/auth/') }}">Log in</a> to post a comment.
+ </p>
{% endif %}
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/Allura/allura/templates/widgets/threads_table.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/threads_table.html b/Allura/allura/templates/widgets/threads_table.html
index 5a52f99..2101606 100644
--- a/Allura/allura/templates/widgets/threads_table.html
+++ b/Allura/allura/templates/widgets/threads_table.html
@@ -22,7 +22,9 @@
<table class="forum-list clear">
<thead>
<tr>
- <th>{{ g.icons['mail'].render(tag='span', title='Subscriptions') }}</th>
+ {% if not c.user.is_anonymous() %}
+ <th>{{ g.icons['mail'].render(tag='span', title='Subscriptions') }}</th>
+ {% endif %}
<th class="topic">Topic</th>
<th>Posts</th>
<th>Views</th>
@@ -32,11 +34,13 @@
<tbody class="forum-list">
{% for thread in value %}
<tr>
- <td>
- <input type="checkbox" name="threads-{{loop.index0}}.subscription"
+ {% if not c.user.is_anonymous() %}
+ <td>
+ <input type="checkbox" name="threads-{{loop.index0}}.subscription"
{% if thread.subscription %}checked="checked"{% endif %}/>
- <input type="hidden" name="threads-{{loop.index0}}._id" value="{{thread._id}}"/>
- </td>
+ <input type="hidden" name="threads-{{loop.index0}}._id" value="{{thread._id}}"/>
+ </td>
+ {% endif %}
{% if not thread.first_post %}
<td class="topic">
{% if 'flags' in thread and 'Sticky' in thread.flags %}
@@ -61,9 +65,7 @@
{% else %}
{% set author = thread.last_post.author() %}
<td>
- <p class="gravatar sm">
By {{lib.gravatar(author, size=16)}} {{lib.user_link(author)}}<br />on {{thread.last_post.timestamp.strftime('%a %b %d, %Y %I:%M %p')}}
- </p>
</td>
{% endif %}
</tr>
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
index b5e560f..852c2d6 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
@@ -25,6 +25,9 @@
{% block edit_box %}
{% if forums | length == 0 %}
<p>You do not have permission to post in any forums.</p>
+ {% if c.user.is_anonymous() %}
+ <p><a href="{{ config.get('auth.login_url', '/auth/') }}">Click here to log in.</a></p>
+ {% endif %}
{% else %}
<div class="editbox">
{{c.new_topic.display(action=c.app.url + 'save_new_topic',show_subject=True,forums=forums, current_forum=current_forum)}}
http://git-wip-us.apache.org/repos/asf/allura/blob/3c0a49ab/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
index 076790a..367cd8a 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
@@ -29,7 +29,7 @@
{% if show_moderate and h.has_access(thread, 'moderate')() %}
{{ g.icons['moderate'].render(id='mod_thread_link') }}
{% endif %}
- {{ g.icons['tag'].render(title='Label This', extra_css='thread_tag') }}
+ {# {{ g.icons['tag'].render(title='Label This', extra_css='thread_tag') }} these labels aren't used anywhere ... #}
{{ g.icons['feed'].render(href='feed.rss', title='Follow This', extra_css='thread_feed0') }}
{% endblock %}