Sha256: 5698a988a3068d01e6768bc83a8509b8fd0ba1853e3051603a6557b4d473544d

Contents?: true

Size: 955 Bytes

Versions: 37

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    module TrusteeZone
      # Exposes the trustee zone for trustee users
      class TrusteesController < Decidim::Elections::TrusteeZone::ApplicationController
        include Decidim::FormFactory

        def show
          enforce_permission_to :view, :trustee, trustee: trustee

          trustee.name ||= current_user.name
        end

        def update
          enforce_permission_to :update, :trustee, trustee: trustee

          form = form(TrusteeForm).from_params(params, trustee: trustee)

          UpdateTrustee.call(form) do
            on(:ok) do
              flash[:notice] = I18n.t("trustees.update.success", scope: "decidim.elections.trustee_zone")
            end

            on(:invalid) do
              flash[:alert] = form.errors.full_messages.to_sentence
            end
          end

          redirect_to trustee_path
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-elections-0.27.9 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.8 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.7 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.6 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.10 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.9 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.5 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.8 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.4 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.3 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.7 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.5 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.2 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.1 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.4 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.0 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.3 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.0.rc2 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.27.0.rc1 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.26.2 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb