Sha256: 4ed1f81788bd11aff4ec63ba1aade561c898173c2d1fb9f31f9c517a058ff6a4

Contents?: true

Size: 1.04 KB

Versions: 7

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 < Rectify::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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-admin-0.18.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.17.2 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.18.0 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.17.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.16.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.17.0 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.16.0 app/commands/decidim/admin/verify_user_group.rb