Class: Decidim::System::OrganizationsController

Inherits:
ApplicationController show all
Defined in:
decidim-system/app/controllers/decidim/system/organizations_controller.rb

Overview

Controller to manage Organizations (tenants).

Instance Method Summary collapse

Methods included from HttpCachingDisabler

#disable_http_caching

Instance Method Details

#createObject


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

def create
  @form = form(RegisterOrganizationForm).from_params(params)

  RegisterOrganization.call(@form) do
    on(:ok) do
      flash[:notice] = t("organizations.create.success", scope: "decidim.system")
      redirect_to organizations_path
    end

    on(:invalid) do
      flash.now[:alert] = t("organizations.create.error", scope: "decidim.system")
      render :new
    end
  end
end

#editObject


40
41
42
43
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 40

def edit
  organization = Organization.find(params[:id])
  @form = form(UpdateOrganizationForm).from_model(organization)
end

#indexObject


32
33
34
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 32

def index
  @organizations = Organization.all
end

#newObject


11
12
13
14
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 11

def new
  @form = form(RegisterOrganizationForm).instance
  @form.file_upload_settings = form(FileUploadSettingsForm).from_model({})
end

#showObject


36
37
38
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 36

def show
  @organization = Organization.find(params[:id])
end

#updateObject


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'decidim-system/app/controllers/decidim/system/organizations_controller.rb', line 45

def update
  @form = form(UpdateOrganizationForm).from_params(params)

  UpdateOrganization.call(params[:id], @form) do
    on(:ok) do
      flash[:notice] = t("organizations.update.success", scope: "decidim.system")
      redirect_to organizations_path
    end

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