forked from bofh/fetsite
AutoCommit Son Aug 2 17:03:02 CEST 2015
This commit is contained in:
@@ -22,8 +22,11 @@ class CommentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def new
|
def new
|
||||||
|
|
||||||
@comment = Comment.new
|
@comment = Comment.new
|
||||||
@comment.commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
@comment.commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
||||||
|
authorize! :comment, @comment.commentable
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
@@ -40,6 +43,7 @@ class CommentsController < ApplicationController
|
|||||||
params_new= params[:comment].select {|i| !["commentable_id", "commentable_type"].include?(i)}
|
params_new= params[:comment].select {|i| !["commentable_id", "commentable_type"].include?(i)}
|
||||||
|
|
||||||
c = params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
|
c = params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
|
||||||
|
authorize! :comment, c
|
||||||
|
|
||||||
@comment = Comment.build_for(c, current_user,"", params_new)
|
@comment = Comment.build_for(c, current_user,"", params_new)
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,12 @@ class Ability
|
|||||||
|
|
||||||
#---------------------------------------------------
|
#---------------------------------------------------
|
||||||
|
|
||||||
can :index, Comment
|
can [:index,:hide], Comment
|
||||||
can :show, Comment
|
can :show, Comment
|
||||||
|
|
||||||
if loggedin
|
if loggedin
|
||||||
can [:create,:new], Comment
|
can [:create,:new], Comment
|
||||||
|
can [:comment], Comment
|
||||||
end
|
end
|
||||||
|
|
||||||
# can :manage, Comment
|
# can :manage, Comment
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
<div id="<%= divid_for(comment) %>">
|
<div id="<%= divid_for(comment) %>">
|
||||||
<% if (!comment.anonym) %>
|
<% if (!comment.anonym) %>
|
||||||
<a class="pull-left media-object" href="#"><%= image_tag comment.thumb_url %></a>
|
<a class="pull-left media-object" href="#"><%= image_tag comment.thumb_url %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<b><%= (!comment.anonym) ? comment.user.try(:email) : "Anonym" %>
|
<b><%= (!comment.anonym) ? comment.user.try(:email) : "Anonym" %>
|
||||||
</b> (<%= I18n.l(comment.created_at) %>)
|
</b> (<%= I18n.l(comment.created_at) %>)
|
||||||
|
|
||||||
<%= link_to ffi1_icon("remove9"), comment_path(comment), method: :delete, data: { confirm: 'Are you sure?' }, remote: true %>:
|
<%= link_to ffi1_icon("remove9"), comment_path(comment), method: :delete, data: { confirm: 'Are you sure?' }, remote: true if can? :destroy, comment %>:
|
||||||
<p>
|
<p>
|
||||||
<%= comment.text %>
|
<%= comment.text %>
|
||||||
<% if can?(:comment, comment.commentable) %>
|
<% if can?(:comment, comment.commentable) && can?(:new, Comment) %>
|
||||||
<br><%= link_to "comment" , new_comment_path( commentable_type: "Comment", commentable_id: comment.id), remote:true %>
|
<br><%= link_to "comment" , new_comment_path( commentable_type: "Comment", commentable_id: comment.id), remote:true %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="<%= divid_for(comment,"newform") %>">
|
<div id="<%= divid_for(comment,"newform") %>">
|
||||||
</div>
|
</div>
|
||||||
<div id="<%= Comment.wrapid_for( comment)%>">
|
<div id="<%= Comment.wrapid_for( comment)%>">
|
||||||
|
<%= render partial:"comments/comments", object: comment.children.order(:created_at).reverse_order if comment.children.size >0 %>
|
||||||
<%= render partial:"comments/comments", object: comment.children.order(:created_at).reverse_order if comment.children.size >0 %>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
<%= link_to "Comments:.."+ comments_block.comments.count().to_s, comments_path(commentable_type: comments_block.class.to_s.gsub("::","_"), commentable_id: comments_block.id), remote:true, id: Comment.switchshowid_for( comments_block) %> <%# load the comments in the comments block %>
|
||||||
|
<p>
|
||||||
<%= link_to "Comment" , new_comment_path( commentable_type: comments_block.class.to_s.gsub("::","_"), commentable_id: comments_block.id), remote:true if can? :comment, comments_block %> <%# This is the button to add a new comment %>
|
<%= link_to "Comment" , new_comment_path( commentable_type: comments_block.class.to_s.gsub("::","_"), commentable_id: comments_block.id), remote:true if can? :comment, comments_block %> <%# This is the button to add a new comment %>
|
||||||
<%= link_to "comments:.."+ comments_block.comments.count().to_s, comments_path(commentable_type: comments_block.class.to_s.gsub("::","_"), commentable_id: comments_block.id), remote:true, id: Comment.switchshowid_for( comments_block) %> <%# load the comments in the comments block %>
|
|
||||||
<div id="<%= divid_for(comments_block,"newform") %>">
|
<div id="<%= divid_for(comments_block,"newform") %>">
|
||||||
</div>
|
</div>
|
||||||
|
</p>
|
||||||
<% unless comments_block.comments.roots.empty? %>
|
<% unless comments_block.comments.roots.empty? %>
|
||||||
|
|
||||||
<div id="<%= Comment.wrapid_for( comments_block)%>">
|
<div id="<%= Comment.wrapid_for( comments_block)%>">
|
||||||
|
|||||||
Reference in New Issue
Block a user