Browse Source

tweaks

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
3dbeb33d89
  1. 2
      app/controllers/cnames_controller.rb
  2. 2
      app/models/ability.rb
  3. 12
      app/models/domain.rb
  4. 2
      app/models/record.rb

2
app/controllers/cnames_controller.rb

@ -1,7 +1,7 @@
class CnamesController < ApplicationController
active_scaffold :cname do |conf|
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.columns[:content].label = 'FQDN'
conf.columns[:content].description = 'Ex. host.domain.com'

2
app/models/ability.rb

@ -5,9 +5,7 @@ class Ability
user ||= User.new
if user.persisted?
can :create, Domain
can :manage, Domain, :user_id => user.id
can :create, Record
can :manage, Record, :domain => {:user_id => user.id}
cannot :delete, SOA # it's deleted with the parent domain
end

12
app/models/domain.rb

@ -3,15 +3,21 @@ class Domain < ActiveRecord::Base
nilify_blanks
belongs_to :user
has_many :records, :dependent => :destroy
has_many :records, :dependent => :destroy, :inverse_of => :domain
cattr_reader :types
@@types = ['NATIVE', 'MASTER', 'SLAVE', 'SUPERSLAVE']
has_one :soa_record, :class_name => 'SOA', :conditions => {:type => 'SOA'}
has_one :soa_record,
:class_name => 'SOA',
:conditions => {:type => 'SOA'},
:inverse_of => :domain
for type in Record.types
has_many :"#{type.downcase}_records", :class_name => type, :conditions => {:type => type}
has_many :"#{type.downcase}_records",
:class_name => type,
:conditions => {:type => type},
:inverse_of => :domain
validates_associated :"#{type.downcase}_records"
end

2
app/models/record.rb

@ -1,5 +1,5 @@
class Record < ActiveRecord::Base
belongs_to :domain
belongs_to :domain, :inverse_of => :records
cattr_reader :types
@@types = %w(SOA NS A MX TXT CNAME)

Loading…
Cancel
Save