Sha256: d7e0f557911f8001f9f0f83cdff397dfa57ce0442a09b30e0a9134d0f1d8bd09

Contents?: true

Size: 1.04 KB

Versions: 25

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A command with all the business logic when verifying a user_group.
    class VerifyUserGroup < Decidim::Command
      # Public: Initializes the command.
      #
      # user_group - The user_group to verify
      # current_user - the user performing the action
      def initialize(user_group, current_user, via_csv: false)
        @user_group = user_group
        @current_user = current_user
        @via_csv = via_csv
      end

      # Executes the command. Broadcasts these events:
      #
      # - :ok when everything is valid.
      #
      # Returns nothing.
      def call
        return broadcast(:invalid) unless @user_group.valid?

        verify_user_group
        broadcast(:ok)
      end

      private

      def verify_user_group
        action = @via_csv ? "verify_via_csv" : "verify"
        Decidim.traceability.perform_action!(
          action,
          @user_group,
          @current_user
        ) do
          @user_group.verify!
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.28.4 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.27.9 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.29.0 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.28.3 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.27.8 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.29.0.rc4 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.29.0.rc3 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.29.0.rc2 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.29.0.rc1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.28.2 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.27.7 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.28.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.27.6 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.28.0 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.27.5 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.27.4 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.27.3 app/commands/decidim/admin/verify_user_group.rb