Class: Admin::Serverless::DomainsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/serverless/domains_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/admin/serverless/domains_controller.rb', line 11

def create
  if PagesDomain.instance_serverless.exists?
    return redirect_to admin_serverless_domains_path, notice: _('An instance-level serverless domain already exists.')
  end

  @domain = PagesDomain.instance_serverless.create(create_params)

  if @domain.persisted?
    redirect_to admin_serverless_domains_path, notice: _('Domain was successfully created.')
  else
    render 'index'
  end
end

#destroyObject


33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/admin/serverless/domains_controller.rb', line 33

def destroy
  if domain.serverless_domain_clusters.exists?
    return redirect_to admin_serverless_domains_path,
                       status: :conflict,
                       notice: _('Domain cannot be deleted while associated to one or more clusters.')
  end

  domain.destroy!

  redirect_to admin_serverless_domains_path,
              status: :found,
              notice: _('Domain was successfully deleted.')
end

#indexObject


7
8
9
# File 'app/controllers/admin/serverless/domains_controller.rb', line 7

def index
  @domain = PagesDomain.instance_serverless.first_or_initialize
end

#updateObject


25
26
27
28
29
30
31
# File 'app/controllers/admin/serverless/domains_controller.rb', line 25

def update
  if domain.update(update_params)
    redirect_to admin_serverless_domains_path, notice: _('Domain was successfully updated.')
  else
    render 'index'
  end
end

#verifyObject


47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/admin/serverless/domains_controller.rb', line 47

def verify
  result = VerifyPagesDomainService.new(domain).execute

  if result[:status] == :success
    flash[:notice] = _('Successfully verified domain ownership')
  else
    flash[:alert] = _('Failed to verify domain ownership')
  end

  redirect_to admin_serverless_domains_path
end