Sha256: 383362460bde4a8ed33766993251609f7ff8e0a70eebe6e74f3ed1795235c369

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

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

      layout "decidim/admin/users"

      def index
        enforce_permission_to :read, :moderate_users

        @moderated_users = filtered_collection.page(params[:page]).per(15)
      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
        UserModeration.joins(:user).where(decidim_users: { decidim_organization_id: current_organization.id })
      end

      def collection
        target_scope = params[:blocked] && params[:blocked] == "true" ? :blocked : :unblocked
        base_query_finder.send(target_scope)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-admin-0.25.2 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.25.1 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.25.0 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.25.0.rc4 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.25.0.rc3 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.25.0.rc2 app/controllers/decidim/admin/moderated_users_controller.rb
decidim-admin-0.25.0.rc1 app/controllers/decidim/admin/moderated_users_controller.rb