Skip to content

Commit

Permalink
Merge pull request #1339 from consul/comments_on_investments
Browse files Browse the repository at this point in the history
Comments on investments
  • Loading branch information
voodoorai2000 committed Jan 10, 2017
2 parents 205b988 + 76d818d commit ccdaca8
Show file tree
Hide file tree
Showing 6 changed files with 504 additions and 4 deletions.
8 changes: 8 additions & 0 deletions app/helpers/comments_helper.rb
Expand Up @@ -20,6 +20,14 @@ def child_comments_of(parent)
end
end

def commentable_path(comment)
if comment.commentable_type == "Budget::Investment"
budget_investment_path(comment.commentable.budget_id, comment.commentable)
else
comment.commentable
end
end

def user_level_class(comment)
if comment.as_administrator?
"is-admin"
Expand Down
2 changes: 1 addition & 1 deletion app/models/abilities/administrator.rb
Expand Up @@ -32,7 +32,7 @@ def initialize(user)
can :mark_featured, Debate
can :unmark_featured, Debate

can :comment_as_administrator, [Debate, Comment, Proposal]
can :comment_as_administrator, [Debate, Comment, Proposal, Budget::Investment]

can [:search, :create, :index, :destroy], ::Moderator
can [:search, :create, :index, :summary], ::Valuator
Expand Down
2 changes: 1 addition & 1 deletion app/models/abilities/moderator.rb
Expand Up @@ -5,7 +5,7 @@ class Moderator
def initialize(user)
self.merge Abilities::Moderation.new(user)

can :comment_as_moderator, [Debate, Comment, Proposal]
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment]
end
end
end
2 changes: 1 addition & 1 deletion app/models/comment.rb
Expand Up @@ -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", "Budget::Investment"]

validate :validate_body_length

Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/show.html.erb
@@ -1,6 +1,6 @@
<div class="row">
<div class="small-12 column margin-top">
<%= link_to @comment.commentable, class: "back" do %>
<%= link_to commentable_path(@comment), class: "back" do %>
<span class="icon-angle-left"></span>
<%= t("comments.show.return_to_commentable") + @comment.commentable.title %>
<% end %>
Expand Down

0 comments on commit ccdaca8

Please sign in to comment.