Class: Decidim::Elections::TrusteeZone::TrusteesController

Inherits:
ApplicationController show all
Includes:
FormFactory
Defined in:
decidim-elections/app/controllers/decidim/elections/trustee_zone/trustees_controller.rb

Overview

Exposes the trustee zone for trustee users

Instance Method Summary collapse

Methods included from UserProfile

#available_verification_workflows

Methods included from UserGroups

#enforce_user_groups_enabled

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#showObject


10
11
12
13
14
# File 'decidim-elections/app/controllers/decidim/elections/trustee_zone/trustees_controller.rb', line 10

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

  trustee.name ||= current_user.name
end

#updateObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'decidim-elections/app/controllers/decidim/elections/trustee_zone/trustees_controller.rb', line 16

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