Sha256: d2d8917916c7cb45a07e441a0cc6c45fb9a41be051634a9e154413e2e090a0a9

Contents?: true

Size: 933 Bytes

Versions: 7

Compression:

Stored size: 933 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.name ||= current_user.name
        end

        def update
          enforce_permission_to(:update, :trustee, trustee:)

          form = form(TrusteeForm).from_params(params, 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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.28.3 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.28.2 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.28.1 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.28.0 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.28.0.rc5 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb
decidim-elections-0.28.0.rc4 app/controllers/decidim/elections/trustee_zone/trustees_controller.rb