Sha256: 1b50d631fd99d34155388c3a077510b7373e5c9ac598ca824c81ad4e15ce3460

Contents?: true

Size: 1.65 KB

Versions: 10

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    class ModeratedUsersController < Decidim::Admin::ApplicationController
      include Decidim::ModeratedUsers::Admin::Filterable

      layout "decidim/admin/global_moderations"

      before_action :set_moderation_breadcrumb_item

      def index
        enforce_permission_to :read, :moderate_users

        @moderated_users = filtered_collection
      end

      def ignore
        enforce_permission_to :unreport, :moderate_users

        Admin::UnreportUser.call(reportable, current_user) do
          on(:ok) do
            flash[:notice] = I18n.t("reportable.unreport.success", scope: "decidim.moderations.admin")
            redirect_to moderated_users_path
          end

          on(:invalid) do
            flash.now[:alert] = I18n.t("reportable.unreport.invalid", scope: "decidim.moderations.admin")
            redirect_to moderated_users_path
          end
        end
      end

      private

      def reportable
        @reportable ||= base_query_finder.find(params[:id]).user
      end

      def base_query_finder
        Decidim::Admin::ModerationStats.new(current_user).user_reports
      end

      def collection
        @collection ||= if params[:blocked]
                          base_query_finder.blocked
                        else
                          base_query_finder.unblocked
                        end
      end

      def set_moderation_breadcrumb_item
        controller_breadcrumb_items << {
          label: I18n.t("menu.reported_users", scope: "decidim.admin"),
          url: decidim_admin.moderated_users_path,
          active: true
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.28.4 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.29.0 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.28.3 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.29.0.rc4 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.29.0.rc3 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.29.0.rc2 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.29.0.rc1 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.28.2 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.28.1 app/controllers/decidim/admin/moderated_users_controller.rb