Sha256: 90b1a7de3ac69b2f777723365042bd9b8f394cbb2331acde17c73be01fe84e19

Contents?: true

Size: 1.52 KB

Versions: 35

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module Decidim
  module System
    # Controller to manage Organizations (tenants).
    #
    class OrganizationsController < Decidim::System::ApplicationController
      def new
        @form = form(RegisterOrganizationForm).instance
      end

      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

      def index
        @organizations = Organization.all
      end

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

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

      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
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
decidim-0.6.3 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.6.2 app/controllers/decidim/system/organizations_controller.rb
decidim-0.6.2 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.6.1 app/controllers/decidim/system/organizations_controller.rb
decidim-0.6.1 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.6.0 app/controllers/decidim/system/organizations_controller.rb
decidim-0.6.0 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.5.1 app/controllers/decidim/system/organizations_controller.rb
decidim-0.5.1 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.5.0 app/controllers/decidim/system/organizations_controller.rb
decidim-0.5.0 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.4.4 app/controllers/decidim/system/organizations_controller.rb
decidim-0.4.4 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.4.3 app/controllers/decidim/system/organizations_controller.rb
decidim-0.4.3 decidim-system/app/controllers/decidim/system/organizations_controller.rb