Sha256: ef23ef7790f546ee7a57966c14aa908d28ab0783be00062807a57902c2843c3a

Contents?: true

Size: 1.12 KB

Versions: 19

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

19 entries across 19 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.9 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.28.3 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.8 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.28.2 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.7 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.28.1 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.6 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.28.0 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.5 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.28.0.rc5 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.28.0.rc4 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.4 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.3 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.2 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.1 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.0 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.0.rc2 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb
decidim-elections-0.27.0.rc1 app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb