Class: Decidim::Admin::OrganizationController

Inherits:
ApplicationController show all
Defined in:
decidim-admin/app/controllers/decidim/admin/organization_controller.rb

Overview

Controller that allows managing the user organization.

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#editObject


10
11
12
13
# File 'decidim-admin/app/controllers/decidim/admin/organization_controller.rb', line 10

def edit
  enforce_permission_to :update, :organization, organization: current_organization
  @form = form(OrganizationForm).from_model(current_organization)
end

#updateObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'decidim-admin/app/controllers/decidim/admin/organization_controller.rb', line 15

def update
  enforce_permission_to :update, :organization, organization: current_organization
  @form = form(OrganizationForm).from_params(params)

  UpdateOrganization.call(current_organization, @form) do
    on(:ok) do
      flash[:notice] = I18n.t("organization.update.success", scope: "decidim.admin")
      redirect_to edit_organization_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("organization.update.error", scope: "decidim.admin")
      render :edit
    end
  end
end

#user_entitiesObject


36
37
38
# File 'decidim-admin/app/controllers/decidim/admin/organization_controller.rb', line 36

def user_entities
  search(current_organization.user_entities)
end

#usersObject


32
33
34
# File 'decidim-admin/app/controllers/decidim/admin/organization_controller.rb', line 32

def users
  search(current_organization.users)
end