diff --git a/app/models/domain.rb b/app/models/domain.rb index 2fdf4c6..6829f81 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -1,33 +1,37 @@ class Domain < ActiveRecord::Base self.inheritance_column = :nx def self.domain_types [ 'NATIVE', 'MASTER', 'SLAVE', ] end has_many :records has_one :soa, class_name: SOA validates :name, uniqueness: true, presence: true validates :type, presence: true, inclusion: { in: domain_types } after_create :generate_soa attr_writer :serial_strategy def serial_strategy @serial_strategy ||= WebDNS.settings[:serial_strategy] end + def reverse? + name.end_with?('.in-addr.arpa') || name.end_with?('.ip6.arpa') + end + private # Hooks def generate_soa soa_record = SOA.new(domain: self) soa_record.save end end diff --git a/app/views/domains/index.html.erb b/app/views/domains/index.html.erb index 758d05f..01071a9 100644 --- a/app/views/domains/index.html.erb +++ b/app/views/domains/index.html.erb @@ -1,22 +1,30 @@
Domain | +Type | Controls | |
---|---|---|---|
<%= link_to domain.name, domain %> | ++ <% if domain.reverse? %> + + <% else %> + + <% end %> + | <%= link_to 'Edit', edit_domain_path(domain) %> | <%= link_to 'Destroy', domain, method: :delete, data: { confirm: 'Are you sure?' } %> |
<%= link_to 'New Domain »'.html_safe, new_domain_path, class: 'btn btn-lg btn-primary' %>
diff --git a/test/factories/domain.rb b/test/factories/domain.rb index 6ff5abf..aa7eba9 100644 --- a/test/factories/domain.rb +++ b/test/factories/domain.rb @@ -1,14 +1,22 @@ FactoryGirl.define do sequence(:domain) { |n| "example#{n}.com" } factory :domain do name { generate(:domain) } serial_strategy Strategies::Date type 'NATIVE' end factory :date_domain, class: Domain do name { generate(:domain) } serial_strategy Strategies::Date type 'NATIVE' end + + factory :v4_arpa_domain, parent: :domain do + name '2.0.192.in-addr.arpa' + end + + factory :v6_arpa_domain, parent: :domain do + name '8.b.d.0.1.0.0.2.ip6.arpa' + end end