Sha256: d6b760427b44541b09f4b2181d44a11e1d76798b00333e439d9394a0e971edaf

Contents?: true

Size: 976 Bytes

Versions: 37

Compression:

Stored size: 976 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class ReportUsersController < ApplicationController
    include FormFactory
    include NeedsPermission

    before_action :authenticate_user!

    def create
      enforce_permission_to :create, :user_report

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

      CreateUserReport.call(@form, reportable, current_user) do
        on(:ok) do
          flash[:notice] = I18n.t("decidim.reports.create.success")
          redirect_back fallback_location: root_path
        end

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

    private

    def reportable
      @reportable ||= GlobalID::Locator.locate_signed params[:sgid]
    end

    def permission_class_chain
      [Decidim::ReportUserPermissions, Decidim::Permissions]
    end

    def permission_scope
      :public
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.8 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.7 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.6 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.10 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.9 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.5 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.8 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.4 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.3 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.7 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.5 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.2 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.1 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.4 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.0 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.3 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.0.rc2 app/controllers/decidim/report_users_controller.rb
decidim-core-0.27.0.rc1 app/controllers/decidim/report_users_controller.rb
decidim-core-0.26.2 app/controllers/decidim/report_users_controller.rb