Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
allow comment spam flagging
  • Loading branch information
bborn committed May 30, 2011
1 parent c630914 commit 0b1311f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/controllers/comments_controller.rb
Expand Up @@ -125,6 +125,9 @@ def create
def destroy
@comment = Comment.find(params[:id])
if @comment.can_be_deleted_by(current_user) && @comment.destroy
if params[:spam] && AppConfig.akismet_key
@comment.spam!
end
flash.now[:notice] = :the_comment_was_deleted.l
else
flash.now[:error] = :comment_could_not_be_deleted.l
Expand All @@ -143,6 +146,7 @@ def delete_selected
if params[:delete]
params[:delete].each { |id|
comment = Comment.find(id)
comment.spam! if params[:spam] && AppConfig.akismet_key
comment.destroy if comment.can_be_deleted_by(current_user)
}
end
Expand Down
20 changes: 16 additions & 4 deletions app/views/admin/comments.html.haml
Expand Up @@ -10,12 +10,19 @@
=f.label :commentable_id.l
=f.text_field :commentable_id

=f.label :name.l
=f.text_field :author_name_or_user_login_like

=f.label :email.l
=f.text_field :author_email_or_user_email_like
=f.text_field :author_email_like

=f.label :comment_web_site_label.l
=f.text_field :author_url_like

=f.label :body_text.l
=f.text_field :comment_like

%p= f.submit :search.l



- form_tag delete_selected_comments_path, :id => 'comments' do
Expand All @@ -31,15 +38,19 @@
%table{"cellspacing"=>"0", "border"=>"0", "cellpadding"=>"0", "width"=>"100%", :style => "table-layout:fixed;"}
%thead
%tr
%th{:width => '30px', :colspan => '2'}
%th{:width => '60px', :colspan => '3'}
%th=:author.l
%th{:width => "250px"}=:body_text.l
%th=:on_commentable.l

%tbody
- @comments.each do |comment|
%tr{:id => "comment_#{comment.id}"}
%td=link_to_remote(image_tag('icons/delete.png', :plugin => 'community_engine'), {:url => comment_path(comment.commentable_type, comment.commentable_id, comment), :method => :delete, 500 => 'alert(\'Sorry, there was a server error\'); return false', :success => visual_effect(:fade, "comment_#{comment.id}"), :confirm => "Are you sure you want to permanently delete this comment"} )
%td
=link_to_remote(image_tag('icons/delete.png', :plugin => 'community_engine'), {:url => comment_path(comment.commentable_type, comment.commentable_id, comment), :method => :delete, 500 => 'alert(\'Sorry, there was a server error\'); return false', :success => visual_effect(:fade, "comment_#{comment.id}"), :confirm => "Are you sure you want to permanently delete this comment"} )
%td
=link_to_remote(image_tag('icons/bad-flag.png', :plugin => 'community_engine'), {:url => comment_path(comment.commentable_type, comment.commentable_id, comment), :method => :delete, 500 => 'alert(\'Sorry, there was a server error\'); return false', :success => visual_effect(:fade, "comment_#{comment.id}"), :confirm => "Are you sure you want to permanently delete this comment and mark it as spam!?"} )

%td= check_box_tag "delete[]", comment.id
%td
.left
Expand All @@ -63,6 +74,7 @@
-if @comments.any?
%a{:href=>"#", :onclick=>"checkboxes.each(function(e){ e.checked = (e.checked == 0 ? 1 : 0) }); return false;"} Toggle all
%p= submit_tag :delete_selected.l
%p= submit_tag :delete_selected_mark_as_spam.l


-if @comments.page_count > 1
Expand Down
2 changes: 2 additions & 0 deletions lang/ui/en.yml
Expand Up @@ -355,6 +355,8 @@ en:
delete: Delete
#en: delete_selected: Delete selected
delete_selected: Delete selected
#en: delete_selected_mark_as_spam: Delete selected and mark spam
delete_selected_mark_as_spam: Delete selected and mark spam
#en: delete_this_event: Delete this event
delete_this_event: Delete this event
#en: delete_this_forum: Delete this forum
Expand Down
Binary file added public/images/icons/bad-flag.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0b1311f

Please sign in to comment.