Sha256: e5eedb8dda410b770cab9ed0756ec217495293b9c929882e5562cbb6d586be34

Contents?: true

Size: 1.44 KB

Versions: 26

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # Controller that allows managing the user organization.
    #
    class OrganizationController < Decidim::Admin::ApplicationController
      layout "decidim/admin/settings"

      def edit
        authorize! :update, current_organization
        @form = form(OrganizationForm).from_model(current_organization)
      end

      def update
        authorize! :update, current_organization
        @form = form(OrganizationForm).from_params(organization_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

      private

      def organization_params
        params[:organization] ||= {}
        params[:organization][:id] ||= current_organization.id
        {
          homepage_image: current_organization.homepage_image,
          logo: current_organization.logo,
          favicon: current_organization.favicon,
          official_img_header: current_organization.official_img_header,
          official_img_footer: current_organization.official_img_footer
        }.merge(params[:organization].to_unsafe_h)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
decidim-admin-0.6.8 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.8 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.7 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.7 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.6 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.6 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.5 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.5 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.4 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.4 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.3 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.3 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.2 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.2 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.1 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.1 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.6.0 app/controllers/decidim/admin/organization_controller.rb
decidim-0.6.0 decidim-admin/app/controllers/decidim/admin/organization_controller.rb
decidim-admin-0.5.1 app/controllers/decidim/admin/organization_controller.rb
decidim-0.5.1 decidim-admin/app/controllers/decidim/admin/organization_controller.rb