adds question comments

This commit is contained in:
rgarcia
2016-11-16 19:41:52 +01:00
parent 6fe965a9b8
commit b104859da3
4 changed files with 35 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ module Abilities
can :mark_featured, Debate
can :unmark_featured, Debate
can :comment_as_administrator, [Debate, Comment, Proposal]
can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question]
can [:search, :create, :index, :destroy], ::Moderator
can [:search, :create, :index, :summary], ::Valuator

View File

@@ -5,7 +5,7 @@ module Abilities
def initialize(user)
self.merge Abilities::Moderation.new(user)
can :comment_as_moderator, [Debate, Comment, Proposal]
can :comment_as_moderator, [Debate, Comment, Proposal, Poll::Question]
end
end
end

View File

@@ -10,7 +10,7 @@ class Comment < ActiveRecord::Base
validates :body, presence: true
validates :user, presence: true
validates_inclusion_of :commentable_type, in: ["Debate", "Proposal"]
validates_inclusion_of :commentable_type, in: ["Debate", "Proposal", "Poll::Question"]
validate :validate_body_length
@@ -95,7 +95,7 @@ class Comment < ActiveRecord::Base
end
def self.body_max_length
Setting['comments_body_max_length'].to_i
Setting['comments_body_max_length'].to_i
end
def calculate_confidence_score

View File

@@ -0,0 +1,31 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@commentable), @comment_tree.comments, @comment_tree.comment_authors, @commentable.comments_count, @comment_flags] do %>
<section class="row-full comments">
<div class="row">
<div id="comments" class="small-12 column">
<h2>
<%= t("shared.comments.title") %>
<span class="js-comments-count">(<%= @commentable.comments_count %>)</span>
</h2>
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render 'comments/form', {commentable: @commentable, parent_id: nil, toggeable: false} %>
<% else %>
<br>
<div data-alert class="callout primary">
<%= t("shared.comments.login_to_comment",
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
</div>
<% end %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render 'comments/comment', comment: comment %>
<% end %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>
</section>
<% end %>