Sha256: dd39ae5a23cce7d6d0887b68d11e522f7c216442309097765497b88e0e9fe939

Contents?: true

Size: 1.53 KB

Versions: 14

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true
require_dependency "decidim/system/application_controller"

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

      def create
        @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 = UpdateOrganizationForm.from_model(organization)
      end

      def update
        @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

14 entries across 14 versions & 2 rubygems

Version Path
decidim-system-0.0.1.alpha9 app/controllers/decidim/system/organizations_controller.rb
decidim-0.0.1.alpha9 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.0.1.alpha8 app/controllers/decidim/system/organizations_controller.rb
decidim-0.0.1.alpha8 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.0.1.alpha7 app/controllers/decidim/system/organizations_controller.rb
decidim-0.0.1.alpha7 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.0.1.alpha6 app/controllers/decidim/system/organizations_controller.rb
decidim-0.0.1.alpha6 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.0.1.alpha5 app/controllers/decidim/system/organizations_controller.rb
decidim-0.0.1.alpha5 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.0.1.alpha4 app/controllers/decidim/system/organizations_controller.rb
decidim-0.0.1.alpha4 decidim-system/app/controllers/decidim/system/organizations_controller.rb
decidim-system-0.0.1.alpha3 app/controllers/decidim/system/organizations_controller.rb
decidim-0.0.1.alpha3 decidim-system/app/controllers/decidim/system/organizations_controller.rb