Browse Source

more friendly A record

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
9ff227f8ff
  1. 1
      app/controllers/as_controller.rb
  2. 6
      app/controllers/domains_controller.rb
  3. 7
      app/models/domain.rb

1
app/controllers/as_controller.rb

@ -3,7 +3,6 @@ class AsController < ApplicationController
conf.list.columns = [:name, :type, :content, :ttl, :prio, :change_date] conf.list.columns = [:name, :type, :content, :ttl, :prio, :change_date]
conf.create.columns = [:name, :content, :ttl,] conf.create.columns = [:name, :content, :ttl,]
conf.update.columns = [:name, :content, :ttl] conf.update.columns = [:name, :content, :ttl]
conf.subform.columns = [:content, :ttl]
conf.columns[:content].label = 'IP' conf.columns[:content].label = 'IP'
conf.columns[:content].description = 'Ex. "10.10.5.12"' conf.columns[:content].description = 'Ex. "10.10.5.12"'
conf.columns[:change_date].list_ui = :timestamp conf.columns[:change_date].list_ui = :timestamp

6
app/controllers/domains_controller.rb

@ -1,13 +1,13 @@
class DomainsController < ApplicationController class DomainsController < ApplicationController
active_scaffold :domain do |conf| active_scaffold :domain do |conf|
conf.columns = [:name, :records, :soa_record, :ns_records, :a_records] conf.columns = [:name, :ip, :records, :soa_record, :ns_records]
conf.list.columns = [:name, :records] conf.list.columns = [:name, :records]
conf.create.columns = [:name, :soa_record, :ns_records, :a_records] conf.create.columns = [:name, :ip, :soa_record, :ns_records]
conf.update.columns = [:name, :soa_record] conf.update.columns = [:name, :soa_record]
conf.columns[:name].description = 'Ex. "domain.com"' conf.columns[:name].description = 'Ex. "domain.com"'
conf.columns[:ip].description = 'Ex. "10.10.5.12", optional IP to associate your domain with'
conf.columns[:ns_records].show_blank_record = false conf.columns[:ns_records].show_blank_record = false
conf.columns[:a_records].show_blank_record = false
conf.actions.exclude :show conf.actions.exclude :show
conf.list.sorting = { :name => :asc } conf.list.sorting = { :name => :asc }
conf.create.link.label = "Add Domain" conf.create.link.label = "Add Domain"

7
app/models/domain.rb

@ -1,6 +1,9 @@
class Domain < ActiveRecord::Base class Domain < ActiveRecord::Base
set_inheritance_column "sti_disabled" set_inheritance_column "sti_disabled"
nilify_blanks nilify_blanks
# optional IP for create form, results in a type A record
attr_accessor :ip
belongs_to :user belongs_to :user
has_many :records, :dependent => :destroy, :inverse_of => :domain has_many :records, :dependent => :destroy, :inverse_of => :domain
@ -34,6 +37,10 @@ class Domain < ActiveRecord::Base
def slave?; self.type == 'SLAVE' end def slave?; self.type == 'SLAVE' end
before_create do
a_records.build(:content => ip) if ip.present?
end
def setup(email) def setup(email)
build_soa_record build_soa_record
soa = soa_record soa = soa_record

Loading…
Cancel
Save