Class: Decidim::ReportUsersController

Inherits:
ApplicationController show all
Includes:
FormFactory, NeedsPermission
Defined in:
app/controllers/decidim/report_users_controller.rb

Instance Method Summary collapse

Methods included from RegistersPermissions

register_permissions

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from TranslatableAttributes

#default_locale?

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/decidim/report_users_controller.rb', line 10

def create
  enforce_permission_to :create, :user_report

  @form = form(Decidim::ReportForm).from_params(params)

  CreateUserReport.call(@form, reportable) do
    on(:ok) do
      flash[:notice] = I18n.t("decidim.reports.create.success")
      if @form.block?
        redirect_to decidim_admin.new_user_block_path(user_id: reportable.id, hide: form.hide?)
      else
        redirect_back fallback_location: root_path
      end
    end

    on(:invalid) do
      flash[:alert] = I18n.t("decidim.reports.create.error")
      redirect_back fallback_location: root_path
    end
  end
end