Browse Source

forms, logic, naming

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
1fa75e95a4
  1. 2
      app/controllers/soas_controller.rb
  2. 11
      app/models/domain.rb
  3. 2
      app/models/record.rb
  4. 3
      app/models/soa.rb

2
app/controllers/soas_controller.rb

@ -1,7 +1,7 @@
class SoasController < ApplicationController class SoasController < ApplicationController
active_scaffold :soa do |conf| active_scaffold :soa do |conf|
conf.columns = [:name, :primary_ns, :contact, :ttl] conf.columns = [:name, :primary_ns, :contact, :ttl]
conf.create.columns = [:primary_ns, :contact, :ttl] conf.create.columns = [:contact, :ttl]
conf.update.columns = [:contact, :ttl] conf.update.columns = [:contact, :ttl]
conf.actions.exclude :delete, :show conf.actions.exclude :delete, :show
end end

11
app/models/domain.rb

@ -33,19 +33,16 @@ class Domain < ActiveRecord::Base
ns_records.build ns_records.build
ns_records.build ns_records.build
soa = soa_record
ns1, ns2 = ns_records ns1, ns2 = ns_records
soa = soa_record
soa.domain = self
soa.contact ||= email
soa.ttl ||= Settings.default_ttl
ns1.domain = self
ns1.content = sample_ns.first ns1.content = sample_ns.first
ns1.ttl ||= Settings.default_ttl ns1.ttl ||= Settings.default_ttl
ns2.domain = self
ns2.content = sample_ns.second ns2.content = sample_ns.second
ns2.ttl ||= Settings.default_ttl ns2.ttl ||= Settings.default_ttl
soa.contact ||= email
soa.ttl ||= Settings.default_ttl
end end
end end

2
app/models/record.rb

@ -24,6 +24,8 @@ class Record < ActiveRecord::Base
def shortname; name.gsub(/\.?#{self.domain.name}$/, '') end def shortname; name.gsub(/\.?#{self.domain.name}$/, '') end
def shortname=(value); self.name = value end def shortname=(value); self.name = value end
def to_label; content end
protected protected
def prepare_name! def prepare_name!

3
app/models/soa.rb

@ -18,6 +18,9 @@ class SOA < Record
before_validation :assemble_content before_validation :assemble_content
before_update :update_serial before_update :update_serial
after_initialize :disassemble_content after_initialize :disassemble_content
before_validation do
self.primary_ns ||= domain.ns_records.first.content
end
# This allows us to have these convenience attributes act like any other # This allows us to have these convenience attributes act like any other
# column in terms of validations # column in terms of validations

Loading…
Cancel
Save