Add reserved domains management #2565

This commit is contained in:
Martin Lensment 2015-07-07 18:52:58 +03:00
parent b9c8aefd19
commit 8ef8147b06
11 changed files with 132 additions and 20 deletions

View 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