Sha256: 1fdcd74b515a7ea79fcb8a86e03f4d4fa71ba404cb7e71e53ac47f3675eb7fe3

Contents?: true

Size: 1012 Bytes

Versions: 16

Compression:

Stored size: 1012 Bytes

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)
        @user_group = user_group
        @current_user = current_user
      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
        Decidim.traceability.perform_action!(
          "verify",
          @user_group,
          @current_user
        ) do
          @user_group.update!(verified_at: Time.current, rejected_at: nil)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-admin-0.14.4 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.14.3 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.14.2 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.14.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.13.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.12.2 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.13.0 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.12.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.13.0.pre1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.12.0 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.11.2 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.12.0.pre app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.11.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.11.0.pre1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.10.1 app/commands/decidim/admin/verify_user_group.rb
decidim-admin-0.10.0 app/commands/decidim/admin/verify_user_group.rb