-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3259 from manyfold3d/submit-reports
Add report buttons on detail pages and model preview cards
- Loading branch information
Showing
11 changed files
with
91 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class ReportsController < ApplicationController | ||
before_action :get_reportable | ||
|
||
def new | ||
@report = Federails::Moderation::Report.new | ||
end | ||
|
||
def create | ||
@report = Federails::Moderation::Report.create report_params.merge({ | ||
federails_actor: current_user.actor, | ||
object: @reportable.actor | ||
}) | ||
redirect_to(@reportable, notice: t(".success")) | ||
end | ||
|
||
private | ||
|
||
def report_params | ||
params.require(:report).permit(:content) | ||
end | ||
|
||
def get_reportable | ||
reportable = params[:reportable_class].constantize | ||
reportable_param = params[:reportable_class].parameterize + "_id" | ||
id = params[reportable_param] | ||
@reportable = policy_scope(reportable).find_param(id) | ||
authorize @reportable | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h3><%= t(".title", type: @reportable.model_name.human, name: @reportable.name) %></h3> | ||
|
||
<p class="lead"><%= t ".description" %></p> | ||
|
||
<%= form_with model: [@reportable, @report] do |form| %> | ||
|
||
<%= text_input_row form, :content %> | ||
|
||
<%= form.submit translate(".submit"), class: "btn btn-primary" %> | ||
|
||
<% 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
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