Sha256: 01aea1bd830cb634de2582f35165b9af8201961a3dd9e780aec9b5e361cceec9

Contents?: true

Size: 1.07 KB

Versions: 72

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Decidim
  # Exposes the report resource so users can report a reportable.
  class ReportsController < Decidim::ApplicationController
    include FormFactory
    include NeedsPermission

    before_action :authenticate_user!

    def create
      enforce_permission_to :create, :moderation

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

      CreateReport.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
      [
        reportable.participatory_space.manifest.permissions_class,
        Decidim::Permissions
      ]
    end

    def permission_scope
      :public
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

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