Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is now possible to report comments
* Renamed PostReport to Report * Added report button to SPV * Updated rspec refs #4732 refs #4710 refs #4711 refs #4517
- Loading branch information
Lukas Matt
committed
May 15, 2014
1 parent
ee6212c
commit 1748d3b
Showing
35 changed files
with
406 additions
and
239 deletions.
There are no files selected for viewing
File renamed without changes
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
app.models.Report = Backbone.Model.extend({ | ||
urlRoot: '/report', | ||
|
||
getReason: function() { | ||
return prompt(Diaspora.I18n.t('report_prompt'), Diaspora.I18n.t('report_prompt_default')); | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
class ReportController < ApplicationController | ||
before_filter :authenticate_user! | ||
before_filter :redirect_unless_admin, :except => [:create] | ||
|
||
def index | ||
@report = Report.where(reviewed: false).all | ||
end | ||
|
||
def update | ||
if Report.where(post_type: params[:type]).exists?(post_id: params[:id]) | ||
mark_as_reviewed | ||
end | ||
redirect_to :action => :index and return | ||
end | ||
|
||
def destroy | ||
if (params[:type].eql? "post") | ||
if Post.exists?(params[:id]) | ||
delete_post | ||
end | ||
elsif (params[:type].eql? "comment") | ||
if Comment.exists?(params[:id]) | ||
delete_comment | ||
end | ||
end | ||
redirect_to :action => :index and return | ||
end | ||
|
||
def create | ||
code = 400 | ||
username = current_user.username | ||
post = Report.new( | ||
:post_id => params[:id], | ||
:post_type => params[:type], | ||
:user_id => username, | ||
:text => params[:text]) | ||
unless Report.where("post_id = ? AND post_type = ?", params[:id], params[:type]).exists?(user_id: username) | ||
result = post.save | ||
code = 200 if result | ||
end | ||
render :nothing => true, :status => code | ||
end | ||
|
||
private | ||
def delete_post | ||
post = Post.find(params[:id]) | ||
current_user.retract(post) | ||
mark_as_reviewed | ||
flash[:notice] = I18n.t 'report.status.destroyed' | ||
end | ||
|
||
def delete_comment | ||
comment = Comment.find(params[:id]) | ||
#current_user.retract(comment) | ||
comment.destroy | ||
mark_as_reviewed | ||
flash[:notice] = I18n.t 'report.status.destroyed' | ||
end | ||
|
||
def mark_as_reviewed | ||
posts = Report.where("post_id = ? AND post_type = ?", params[:id], params[:type]) | ||
posts.each do |post| | ||
post.update_attributes(reviewed: true) | ||
end | ||
flash[:notice] = I18n.t 'report.status.marked' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2012, Diaspora Inc. This file is | ||
# licensed under the Affero General Public License version 3 or later. See | ||
# the COPYRIGHT file. | ||
|
||
module ReportHelper | ||
def report_content(id, type) | ||
if type.eql? "post" | ||
raw t('report.post_label', title: link_to(post_page_title(Post.find_by_id(id)), post_path(id))) | ||
elsif type.eql? "comment" | ||
raw t('report.comment_label', data: comment_message(Comment.find_by_id(id))) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.