Disallow valuation comment creation on finished budget

This commit is contained in:
Bertocq
2018-01-31 16:36:06 +01:00
parent b926740a32
commit 9cb4b03276
4 changed files with 21 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
<% valuation = local_assigns.fetch(:valuation, false) %> <% valuation = local_assigns.fetch(:valuation, false) %>
<% allow_votes = local_assigns.fetch(:allow_votes, true) %> <% allow_votes = local_assigns.fetch(:allow_votes, true) %>
<% allow_flagging = local_assigns.fetch(:allow_flagging, true) %> <% allow_flagging = local_assigns.fetch(:allow_flagging, true) %>
<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %> <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %>
<ul id="<%= dom_id(comment) %>" class="comment no-bullet small-12"> <ul id="<%= dom_id(comment) %>" class="comment no-bullet small-12">
<li class="comment-body"> <li class="comment-body">
@@ -94,10 +95,12 @@
<%= render 'comments/actions', { comment: comment, <%= render 'comments/actions', { comment: comment,
allow_flagging: allow_flagging } %> allow_flagging: allow_flagging } %>
<%= render 'comments/form', {commentable: comment.commentable, <% if allow_comments %>
parent_id: comment.id, <%= render 'comments/form', {commentable: comment.commentable,
toggeable: true, parent_id: comment.id,
valuation: valuation } %> toggeable: true,
valuation: valuation } %>
<% end %>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
@@ -110,7 +113,8 @@
<%= render 'comments/comment', { comment: child, <%= render 'comments/comment', { comment: child,
valuation: valuation, valuation: valuation,
allow_votes: allow_votes, allow_votes: allow_votes,
allow_flagging: allow_flagging } %> allow_flagging: allow_flagging,
allow_comments: allow_comments } %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@@ -1,5 +1,6 @@
<% commentable = comment_tree.commentable %> <% commentable = comment_tree.commentable %>
<% valuation = local_assigns.fetch(:valuation, false) %> <% valuation = local_assigns.fetch(:valuation, false) %>
<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
<% cache [locale_and_user_status, comment_tree.order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %> <% cache [locale_and_user_status, comment_tree.order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %>
<section class="expanded comments"> <section class="expanded comments">
<div class="row"> <div class="row">
@@ -24,7 +25,7 @@
<div data-alert class="callout primary"> <div data-alert class="callout primary">
<%= t("comments.verified_only", verify_account: link_to(t("comments.verify_account"), verification_path )).html_safe %> <%= t("comments.verified_only", verify_account: link_to(t("comments.verify_account"), verification_path )).html_safe %>
</div> </div>
<% else %> <% elsif allow_comments %>
<%= render 'comments/form', { commentable: commentable, <%= render 'comments/form', { commentable: commentable,
parent_id: nil, parent_id: nil,
toggeable: false, toggeable: false,
@@ -44,7 +45,8 @@
comment_flags: comment_flags, comment_flags: comment_flags,
valuation: valuation, valuation: valuation,
allow_votes: !valuation, allow_votes: !valuation,
allow_flagging: !valuation } %> allow_flagging: !valuation,
allow_comments: allow_comments } %>
<% end %> <% end %>
<%= paginate comment_tree.root_comments %> <%= paginate comment_tree.root_comments %>
</div> </div>

View File

@@ -1,3 +1,5 @@
<% valuation = local_assigns.fetch(:valuation, false) %>
<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@investment), @comment_tree.comments, @comment_tree.comment_authors, @investment.comments_count, @comment_flags] do %> <% cache [locale_and_user_status, @current_order, commentable_cache_key(@investment), @comment_tree.comments, @comment_tree.comment_authors, @investment.comments_count, @comment_flags] do %>
<section class="expanded comments"> <section class="expanded comments">
<div class="row"> <div class="row">
@@ -9,11 +11,11 @@
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
<% if user_signed_in? %> <% if user_signed_in? && allow_comments %>
<%= render 'comments/form', { commentable: @investment, <%= render 'comments/form', { commentable: @investment,
parent_id: nil, parent_id: nil,
toggeable: false, toggeable: false,
valuation: local_assigns.fetch(:valuation, false) } %> valuation: valuation } %>
<% else %> <% else %>
<br> <br>
@@ -26,7 +28,8 @@
<% @comment_tree.root_comments.each do |comment| %> <% @comment_tree.root_comments.each do |comment| %>
<%= render 'comments/comment', { comment: comment, <%= render 'comments/comment', { comment: comment,
valuation: local_assigns.fetch(:valuation, false) } %> valuation: valuation,
allow_comments: allow_comments } %>
<% end %> <% end %>
<%= paginate @comment_tree.root_comments %> <%= paginate @comment_tree.root_comments %>
</div> </div>

View File

@@ -3,5 +3,6 @@
<%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree,
comment_flags: @comment_flags, comment_flags: @comment_flags,
display_comments_count: false, display_comments_count: false,
valuation: true } %> valuation: true,
allow_comments: !@budget.finished? } %>
<% end %> <% end %>