Sha256: ad952db7d4915feca7a0dad3ad92e16a2782cce17f5e370be6a5b452c2081c18

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 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, current_user) 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

5 entries across 5 versions & 1 rubygems

Version Path
decidim-admin-0.29.0 app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb
decidim-admin-0.29.0.rc4 app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb
decidim-admin-0.29.0.rc3 app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb
decidim-admin-0.29.0.rc2 app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb
decidim-admin-0.29.0.rc1 app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb