Browse Source

fix create domain form, validation

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
fa2b718d16
  1. 1
      app/controllers/ns_controller.rb
  2. 7
      app/models/soa.rb

1
app/controllers/ns_controller.rb

@ -3,6 +3,7 @@ class NsController < 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 = 'NS' conf.columns[:content].label = 'NS'
conf.columns[:change_date].list_ui = :timestamp conf.columns[:change_date].list_ui = :timestamp
conf.actions.exclude :show conf.actions.exclude :show

7
app/models/soa.rb

@ -7,9 +7,10 @@
# Obtained from http://www.zytrax.com/books/dns/ch8/soa.html # Obtained from http://www.zytrax.com/books/dns/ch8/soa.html
# #
class SOA < Record class SOA < Record
validates :domain_id, :presence => true, :uniqueness => true # one SOA per domain validates :domain, :presence => true
validates :domain_id, :uniqueness => true # one SOA per domain
validates :name, :presence => true, :hostname => true validates :name, :presence => true, :hostname => true
validate :name_equals_dmain_name? validate :name_equals_domain_name?
validates :content, :presence => true validates :content, :presence => true
validates :primary_ns, :presence => true validates :primary_ns, :presence => true
CONTACT_FORMAT = /\A[a-zA-Z0-9\-\.]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,6}\z/ CONTACT_FORMAT = /\A[a-zA-Z0-9\-\.]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,6}\z/
@ -74,7 +75,7 @@ class SOA < Record
update_serial if @serial.nil? || @serial.zero? update_serial if @serial.nil? || @serial.zero?
end end
def name_equals_dmain_name? def name_equals_domain_name?
unless name == domain.name unless name == domain.name
errors.add :name, "must be equal to domain's name" errors.add :name, "must be equal to domain's name"
end end

Loading…
Cancel
Save