Sha256: fba3f9886b7ecb931b412c8b6bf85161af4ac2ea973256b45e271cc33e565f08

Contents?: true

Size: 1.12 KB

Versions: 25

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    module Admin
      # This command is executed when the admin user removes a trustee
      # from a participatory space from the admin panel.
      class RemoveTrusteeFromParticipatorySpace < Rectify::Command
        # Public: Initializes the command.
        #
        # trustee_participatory_space - A trustee_participatory_space
        def initialize(trustee_participatory_space)
          @trustee_participatory_space = trustee_participatory_space
        end

        # Removes the trustee from participatory space if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if !trustee_participatory_space || trustee_participatory_space.trustee.elections.any?

          remove_trustee_from_participatory_space!

          broadcast(:ok, trustee_participatory_space.trustee)
        end

        private

        attr_reader :trustee_participatory_space

        def remove_trustee_from_participatory_space!
          trustee_participatory_space.trustee.delete
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-elections-0.26.10 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.9 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.8 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.7 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.5 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.4 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.3 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.2 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.1 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.0 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.0.rc2 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.26.0.rc1 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.25.2 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.25.1 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.25.0 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.25.0.rc4 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.25.0.rc3 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.25.0.rc2 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.25.0.rc1 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.24.3 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb