Sha256: fad82389eb940f4ffeb21b40614334c6c073cd487b8543f473e9e46191c44d4a

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    class OrganizationExternalDomainAllowlistController < Decidim::Admin::ApplicationController
      layout "decidim/admin/settings"

      add_breadcrumb_item_from_menu :admin_settings_menu

      helper_method :blank_external_domain

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

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

        UpdateExternalDomainAllowlist.call(@form, current_organization) do
          on(:ok) do
            flash[:notice] = t("domain_allowlist.update.success", scope: "decidim.admin")
            redirect_to edit_organization_external_domain_allowlist_path
          end
          on(:invalid) do
            flash[:notice] = t("domain_allowlist.update.error", scope: "decidim.admin")
            render action: "edit"
          end
        end
      end

      private

      def blank_external_domain
        @blank_external_domain ||= Admin::ExternalDomainForm.new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb