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

@ -13,10 +13,12 @@ class Admin::BlockedDomainsController < AdminController
if bd.update(names: names)
flash[:notice] = I18n.t('record_updated')
redirect_to :back
else
@blocked_domains = params[:blocked_domains]
flash.now[:alert] = I18n.t('failed_to_update_record')
render :index
end
redirect_to :back
end
end

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

View file

@ -107,6 +107,7 @@ class Ability
customer_service
can :manage, Setting
can :manage, BlockedDomain
can :manage, ReservedDomain
can :manage, ZonefileSetting
can :manage, DomainVersion
can :manage, Pricelist

View file

@ -0,0 +1,10 @@
= render 'shared/title', name: t(:reserved_domains)
= form_tag([:admin, :reserved_domains]) do |f|
.row
.col-md-12
= text_area_tag :reserved_domains, @reserved_domains, class: 'form-control', rows: 30
%hr
.row
.col-md-12.text-right
%button.btn.btn-warning=t(:save)