Browse Source

update domain with no ns issue, warn when no more ns's, hxr acl response

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
55e606816a
  1. 9
      app/controllers/application_controller.rb
  2. 7
      app/controllers/ns_controller.rb
  3. 2
      app/models/domain.rb

9
app/controllers/application_controller.rb

@ -5,16 +5,21 @@ class ApplicationController < ActionController::Base
rescue_from CanCan::AccessDenied, ActiveScaffold::ActionNotAllowed do |exception|
flash.now[:error] = exception.message
render :template => 'errors/access_denied', :layout => 'errors'
render_access_denied
end
rescue_from ActiveScaffold::ActionNotAllowed do |exception|
flash.now[:error] = I18n.t("errors.action_not_allowed")
render :template => 'errors/access_denied', :layout => 'errors'
render_access_denied
end
protected
def render_access_denied
layout = request.xhr? ? false : 'errors'
render :template => 'errors/access_denied', :layout => layout
end
def ensure_nested_under_domain
raise CanCan::AccessDenied, "not found" unless nested? and nested_parent_record.is_a?(Domain)
end

7
app/controllers/ns_controller.rb

@ -35,4 +35,11 @@ class NsController < ApplicationController
nested_singular_association? # || params[:parent_sti]
end
def do_destroy
super
if successful? && nested_parent_record.ns_records.count == 0
flash[:warning] = "All NS records deleted, no other nameservers are associated with this domain!"
end
end
end

2
app/models/domain.rb

@ -30,7 +30,7 @@ class Domain < ActiveRecord::Base
validates :type, :inclusion => { :in => @@types, :message => "Unknown domain type" }
validates :soa_record, :presence => {:unless => :slave?}
validates_associated :soa_record #, :allow_nil => true
validates :ns_records, :presence => true, :length => {
validates :ns_records, :on => :create, :presence => true, :length => {
:minimum => 2, :maximum => 10,
:message => "must have be at least 2, at most 10"}
validates_associated :records

Loading…
Cancel
Save