mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 10:45:58 +02:00
Add reserved domains management #2565
This commit is contained in:
parent
b9c8aefd19
commit
8ef8147b06
11 changed files with 132 additions and 20 deletions
30
app/controllers/admin/reserved_domains_controller.rb
Normal file
30
app/controllers/admin/reserved_domains_controller.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
class Admin::ReservedDomainsController < AdminController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
rd = ReservedDomain.first_or_initialize
|
||||
@reserved_domains = rd.names.to_yaml
|
||||
end
|
||||
|
||||
def create
|
||||
@reserved_domains = params[:reserved_domains]
|
||||
|
||||
begin
|
||||
names = YAML.load(params[:reserved_domains])
|
||||
rescue
|
||||
flash.now[:alert] = I18n.t('invalid_yaml')
|
||||
logger.warn 'Invalid YAML'
|
||||
render :index and return
|
||||
end
|
||||
|
||||
rd = ReservedDomain.first_or_create
|
||||
|
||||
if rd.update(names: names)
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to :back
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
render :index
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue