Fixed comments disregarding viewUsers privilege
This commit is contained in:
parent
4b4ccf365a
commit
736c0a66ff
6 changed files with 22 additions and 18 deletions
|
@ -138,7 +138,7 @@
|
|||
<script type="text/javascript" src="/js/Presenters/PostPresenter.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/js/Presenters/GlobalCommentListPresenter.js"></script>
|
||||
<script type="text/javascript" src="/js/Presenters/PostCommentListPresenter.js"></script>
|
||||
<script type="text/javascript" src="/js/Presenters/CommentListPresenter.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/js/Presenters/TagListPresenter.js"></script>
|
||||
<script type="text/javascript" src="/js/Presenters/TagPresenter.js"></script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var App = App || {};
|
||||
App.Presenters = App.Presenters || {};
|
||||
|
||||
App.Presenters.PostCommentListPresenter = function(
|
||||
App.Presenters.CommentListPresenter = function(
|
||||
_,
|
||||
jQuery,
|
||||
util,
|
||||
|
@ -26,14 +26,16 @@ App.Presenters.PostCommentListPresenter = function(
|
|||
privileges = {
|
||||
canListComments: auth.hasPrivilege(auth.privileges.listComments),
|
||||
canAddComments: auth.hasPrivilege(auth.privileges.addComments),
|
||||
editOwnComments: auth.hasPrivilege(auth.privileges.editOwnComments),
|
||||
editAllComments: auth.hasPrivilege(auth.privileges.editAllComments),
|
||||
deleteOwnComments: auth.hasPrivilege(auth.privileges.deleteOwnComments),
|
||||
deleteAllComments: auth.hasPrivilege(auth.privileges.deleteAllComments),
|
||||
canEditOwnComments: auth.hasPrivilege(auth.privileges.editOwnComments),
|
||||
canEditAllComments: auth.hasPrivilege(auth.privileges.editAllComments),
|
||||
canDeleteOwnComments: auth.hasPrivilege(auth.privileges.deleteOwnComments),
|
||||
canDeleteAllComments: auth.hasPrivilege(auth.privileges.deleteAllComments),
|
||||
canViewUsers: auth.hasPrivilege(auth.privileges.viewUsers),
|
||||
canViewPosts: auth.hasPrivilege(auth.privileges.viewPosts),
|
||||
};
|
||||
|
||||
promise.wait(
|
||||
util.promiseTemplate('post-comment-list'),
|
||||
util.promiseTemplate('comment-list'),
|
||||
util.promiseTemplate('comment-list-item'),
|
||||
util.promiseTemplate('comment-form'))
|
||||
.then(function(
|
||||
|
@ -103,8 +105,10 @@ App.Presenters.PostCommentListPresenter = function(
|
|||
formatRelativeTime: util.formatRelativeTime,
|
||||
formatMarkdown: util.formatMarkdown,
|
||||
canVote: auth.isLoggedIn(),
|
||||
canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.editOwnComments : privileges.editAllComments,
|
||||
canDeleteComment: auth.isLoggedIn(comment.user.name) ? privileges.deleteOwnComments : privileges.deleteAllComments,
|
||||
canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.canEditOwnComments : privileges.canEditAllComments,
|
||||
canDeleteComment: auth.isLoggedIn(comment.user.name) ? privileges.canDeleteOwnComments : privileges.canDeleteAllComments,
|
||||
canViewUsers: privileges.canViewUsers,
|
||||
canViewPosts: privileges.canViewPosts,
|
||||
}) + '</li>');
|
||||
util.loadImagesNicely($item.find('img'));
|
||||
$targetList.append($item);
|
||||
|
@ -227,4 +231,4 @@ App.Presenters.PostCommentListPresenter = function(
|
|||
|
||||
};
|
||||
|
||||
App.DI.register('postCommentListPresenter', ['_', 'jQuery', 'util', 'promise', 'api', 'auth', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.PostCommentListPresenter);
|
||||
App.DI.register('commentListPresenter', ['_', 'jQuery', 'util', 'promise', 'api', 'auth', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.CommentListPresenter);
|
|
@ -72,7 +72,7 @@ App.Presenters.GlobalCommentListPresenter = function(
|
|||
}) + '</li>');
|
||||
|
||||
util.loadImagesNicely($post.find('img'));
|
||||
var presenter = App.DI.get('postCommentListPresenter');
|
||||
var presenter = App.DI.get('commentListPresenter');
|
||||
|
||||
presenter.init({
|
||||
post: post,
|
||||
|
|
|
@ -14,7 +14,7 @@ App.Presenters.PostPresenter = function(
|
|||
postsAroundCalculator,
|
||||
postEditPresenter,
|
||||
postContentPresenter,
|
||||
postCommentListPresenter,
|
||||
commentListPresenter,
|
||||
topNavigationPresenter,
|
||||
messagePresenter) {
|
||||
|
||||
|
@ -70,7 +70,7 @@ App.Presenters.PostPresenter = function(
|
|||
presenterManager.initPresenters([
|
||||
[postContentPresenter, {post: post, $target: $el.find('#post-content-target')}],
|
||||
[postEditPresenter, {post: post, $target: $el.find('#post-edit-target'), updateCallback: postEdited}],
|
||||
[postCommentListPresenter, {post: post, $target: $el.find('#post-comments-target')}]],
|
||||
[commentListPresenter, {post: post, $target: $el.find('#post-comments-target')}]],
|
||||
function() { });
|
||||
|
||||
}).fail(function() {
|
||||
|
@ -333,7 +333,7 @@ App.DI.register('postPresenter', [
|
|||
'postsAroundCalculator',
|
||||
'postEditPresenter',
|
||||
'postContentPresenter',
|
||||
'postCommentListPresenter',
|
||||
'commentListPresenter',
|
||||
'topNavigationPresenter',
|
||||
'messagePresenter'],
|
||||
App.Presenters.PostPresenter);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="comment">
|
||||
<div class="avatar">
|
||||
<% if (comment.user.name) { %>
|
||||
<% if (comment.user.name && canViewUsers) { %>
|
||||
<a href="#/user/<%= comment.user.name %>">
|
||||
<% } %>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
|||
src="/data/thumbnails/40x40/avatars/<%= comment.user.name || '!' %>"
|
||||
alt="<%= comment.user.name || 'Anonymous user' %>"/>
|
||||
|
||||
<% if (comment.user.name) { %>
|
||||
<% if (comment.user.name && canViewUsers) { %>
|
||||
</a>
|
||||
<% } %>
|
||||
</div>
|
||||
|
@ -16,13 +16,13 @@
|
|||
<div class="body">
|
||||
<div class="header">
|
||||
<span class="nickname">
|
||||
<% if (comment.user.name) { %>
|
||||
<% if (comment.user.name && canViewUsers) { %>
|
||||
<a href="#/user/<%= comment.user.name %>">
|
||||
<% } %>
|
||||
|
||||
<%= comment.user.name || 'Anonymous user' %>
|
||||
|
||||
<% if (comment.user.name) { %>
|
||||
<% if (comment.user.name && canViewUsers) { %>
|
||||
</a>
|
||||
<% } %>
|
||||
</span>
|
||||
|
|
Loading…
Reference in a new issue