Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F1614920
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Mar 21, 11:24 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Mon, Mar 23, 11:24 AM (23 h, 2 m)
Engine
blob
Format
Raw Data
Handle
352849
Attached To
rWEBDNS WebDNS (edet4)
View Options
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 @@
<table class="table table-striped">
<thead>
<tr>
<th>Domain</th>
+ <th>Type</th>
<th colspan="2">Controls</th>
</tr>
</thead>
<tbody>
<% @domains.each do |domain| %>
<tr>
<td><%= link_to domain.name, domain %></td>
+ <td>
+ <% if domain.reverse? %>
+ <abbr title="Reverse"><span class="glyphicon glyphicon-chevron-left"></span></abbr>
+ <% else %>
+ <abbr title="Forward"><span class="glyphicon glyphicon-chevron-right"></span></abbr>
+ <% end %>
+ </td>
<td><%= link_to 'Edit', edit_domain_path(domain) %></td>
<td><%= link_to 'Destroy', domain, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<p>
<%= link_to 'New Domain »'.html_safe, new_domain_path, class: 'btn btn-lg btn-primary' %>
</p>
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
Event Timeline
Log In to Comment