Class: Decidim::ReportsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Decidim::ReportsController
- Includes:
- FormFactory, NeedsPermission
- Defined in:
- decidim-core/app/controllers/decidim/reports_controller.rb
Overview
Exposes the report resource so users can report a reportable. Unless the reportable is marked as hideable, the resource notice will change accordingly.
Instance Method Summary collapse
Methods included from RegistersPermissions
Methods inherited from ApplicationController
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from Headers::HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'decidim-core/app/controllers/decidim/reports_controller.rb', line 12 def create :create, :moderation @form = form(Decidim::ReportForm).from_params(params, can_hide: reportable.try(:can_be_administered_by?, current_user)) CreateReport.call(@form, reportable) do on(:ok) do flash[:notice] = if hideable? I18n.t("decidim.reports.hide.success") else I18n.t("decidim.reports.create.success") end redirect_to reportable.reload.reported_content_url end on(:invalid) do flash[:alert] = I18n.t("decidim.reports.create.error") redirect_back fallback_location: root_path end end end |