diff --git a/Gemfile b/Gemfile index a277327..55697f0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.2.11' +gem 'rails', '3.2.12' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' @@ -30,10 +30,8 @@ gem 'rails-backbone', '~> 0.7.0' gem 'acts_as_nested_interval', '~> 0.0.7' # path: '/home/clyfe/dev/acts_as_nested_interval' # git: 'https://github.com/clyfe/acts_as_nested_interval.git' -gem 'webshims-rails', '~> 0.2' -gem 'font-awesome-sass-rails', '~> 2.0.0.0' gem 'seedbank', '~> 0.1.3' -gem 'rails_admin', '~> 0.0.5' +gem 'rails_admin', '~> 0.4.5' gem 'rails-settings-cached', '~> 0.2.2' gem 'unicorn', '~> 4.5.0' gem "audited-activerecord", '~> 3.0' @@ -43,18 +41,20 @@ gem "audited-activerecord", '~> 3.0' group :assets do gem 'sass-rails', " ~> 3.2.3" gem 'compass-rails', '~> 1.0.3' - gem 'bootstrap-sass', '~> 2.1.0.0' + gem 'bootstrap-sass', '~> 2.2.0' + gem 'font-awesome-sass-rails', '~> 3.0.0' + gem 'webshims-rails', '~> 0.4.7' gem 'coffee-rails', "~> 3.2.1" gem 'uglifier', '>= 1.0.3' gem 'therubyracer' end -gem 'jquery-rails' -gem 'dalli', '~> 1.1.3' -gem 'active_scaffold', '~> 3.2.16' +gem 'jquery-rails', '~> 2.1.3' +gem 'dalli', '~> 2.6.2' +gem 'active_scaffold', '~> 3.2.19' # git: 'https://github.com/activescaffold/active_scaffold.git' # path: '/home/clyfe/dev/active_scaffold' -gem 'turbolinks', '~> 0.5.1' +gem 'turbolinks', '~> 1.0.0' # gem 'foreigner' ? group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 86725ee..77be95c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,16 +21,16 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.11) - actionpack (= 3.2.11) + actionmailer (3.2.12) + actionpack (= 3.2.12) mail (~> 2.4.4) - actionpack (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) + actionpack (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) - rack (~> 1.4.0) + rack (~> 1.4.5) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) @@ -39,18 +39,18 @@ GEM mail active_scaffold (3.2.19) rails (>= 3.1.3) - activemodel (3.2.11) - activesupport (= 3.2.11) + activemodel (3.2.12) + activesupport (= 3.2.12) builder (~> 3.0.0) - activerecord (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) + activerecord (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - activesupport (3.2.11) + activeresource (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) + activesupport (3.2.12) i18n (~> 0.6) multi_json (~> 1.0) acts_as_nested_interval (0.0.10) @@ -60,9 +60,9 @@ GEM audited-activerecord (3.0.0) activerecord (~> 3.0) audited (= 3.0.0) - bbenezech-nested_form (0.0.6) bcrypt-ruby (3.0.1) - bootstrap-sass (2.1.0.1) + bootstrap-sass (2.2.2.0) + sass (~> 3.2) builder (3.0.4) cancan (1.6.7) capistrano (2.9.0) @@ -80,17 +80,17 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.7) - ffi (~> 1.0, >= 1.0.6) + childprocess (0.3.9) + ffi (~> 1.0, >= 1.0.11) chunky_png (1.2.7) - coderay (1.0.8) + coderay (1.0.9) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) + coffee-script-source (1.6.1) compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) @@ -99,7 +99,7 @@ GEM compass (>= 0.12.2, < 0.14) concerned_with (0.1.0) daemons (1.0.10) - dalli (1.1.5) + dalli (2.6.2) database_cleaner (0.7.2) devise (2.1.3) bcrypt-ruby (~> 3.0) @@ -121,7 +121,7 @@ GEM ffi (1.0.11) file-tail (1.0.12) tins (~> 0.5) - font-awesome-sass-rails (2.0.0.0) + font-awesome-sass-rails (3.0.2.2) railties (>= 3.1.1) sass-rails (>= 3.1.1) fssm (0.2.10) @@ -137,18 +137,19 @@ GEM guard-spork (0.5.2) guard (>= 0.10.0) spork (>= 0.8.4) - haml (3.1.7) + haml (4.0.0) + tilt highline (1.6.15) hike (1.2.1) - i18n (0.6.1) + i18n (0.6.4) journey (1.0.4) - jquery-rails (2.2.0) + jquery-rails (2.1.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (1.1.1) + jquery-ui-rails (3.0.1) jquery-rails railties (>= 3.1.0) - json (1.7.6) + json (1.7.7) kaminari (0.14.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -156,7 +157,7 @@ GEM libnotify (0.7.4) ffi (~> 1.0.11) libv8 (3.11.8.13) - listen (0.7.2) + listen (0.7.3) lumberjack (1.0.2) mail (2.4.4) i18n (>= 0.4.0) @@ -164,19 +165,20 @@ GEM treetop (~> 1.4.8) mail_form (1.3.0) method_source (0.8.1) - mime-types (1.20.1) + mime-types (1.21) mongrel (1.2.0.pre2) daemons (~> 1.0.10) gem_plugin (~> 0.2.3) - multi_json (1.5.0) + multi_json (1.6.1) mysql2 (0.3.11) - net-scp (1.0.4) - net-ssh (>= 1.99.1) - net-sftp (2.0.5) - net-ssh (>= 2.0.9) - net-ssh (2.6.3) - net-ssh-gateway (1.1.0) - net-ssh (>= 1.99.1) + nested_form (0.3.1) + net-scp (1.1.0) + net-ssh (>= 2.6.5) + net-sftp (2.1.1) + net-ssh (>= 2.6.5) + net-ssh (2.6.6) + net-ssh-gateway (1.2.0) + net-ssh (>= 2.6.5) nilify_blanks (1.0.0) activerecord (>= 3.0.0) activesupport (>= 3.0.0) @@ -185,13 +187,13 @@ GEM polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) - pry (0.9.11.4) + pry (0.9.12) coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - quiet_assets (1.0.1) - railties (~> 3.1) - rack (1.4.4) + quiet_assets (1.0.2) + railties (>= 3.1, < 5.0) + rack (1.4.5) rack-cache (1.2) rack (>= 0.4) rack-pjax (0.7.0) @@ -201,38 +203,40 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.11) - actionmailer (= 3.2.11) - actionpack (= 3.2.11) - activerecord (= 3.2.11) - activeresource (= 3.2.11) - activesupport (= 3.2.11) + rails (3.2.12) + actionmailer (= 3.2.12) + actionpack (= 3.2.12) + activerecord (= 3.2.12) + activeresource (= 3.2.12) + activesupport (= 3.2.12) bundler (~> 1.0) - railties (= 3.2.11) + railties (= 3.2.12) rails-backbone (0.7.2) coffee-script (~> 2.2.0) ejs (~> 1.0.0) railties (>= 3.1.0) rails-settings-cached (0.2.4) rails (>= 3.0.0) - rails_admin (0.0.5) - bbenezech-nested_form (~> 0.0.6) - bootstrap-sass (~> 2.0, >= 2.0.3) + rails_admin (0.4.5) + bootstrap-sass (~> 2.2) builder (~> 3.0) coffee-rails (~> 3.1) - haml (~> 3.1) - jquery-rails (>= 1.0.17) - jquery-ui-rails (>= 0.5, < 2) - kaminari (~> 0.12) - rack-pjax (~> 0.5) + font-awesome-sass-rails (~> 3.0, >= 3.0.0.1) + haml (~> 4.0) + jquery-rails (~> 2.1) + jquery-ui-rails (~> 3.0) + kaminari (~> 0.14) + nested_form (~> 0.3) + rack-pjax (~> 0.6) rails (~> 3.1) remotipart (~> 1.0) + safe_yaml (~> 0.6) sass-rails (~> 3.1) rails_config (0.2.7) activesupport (>= 3.0) - railties (3.2.11) - actionpack (= 3.2.11) - activesupport (= 3.2.11) + railties (3.2.12) + actionpack (= 3.2.12) + activesupport (= 3.2.12) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -241,10 +245,10 @@ GEM rake (10.0.3) rb-inotify (0.8.8) ffi (>= 0.5.0) - rdoc (3.12) + rdoc (3.12.2) json (~> 1.4) ref (1.0.2) - remotipart (1.0.2) + remotipart (1.0.5) rspec (2.10.0) rspec-core (~> 2.10.0) rspec-expectations (~> 2.10.0) @@ -264,13 +268,14 @@ GEM ruby_parser (2.3.1) sexp_processor (~> 3.0) rubyzip (0.9.9) - sass (3.2.5) + safe_yaml (0.8.4) + sass (3.2.6) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) seedbank (0.1.3) - selenium-webdriver (2.29.0) + selenium-webdriver (2.31.0) childprocess (>= 0.2.5) multi_json (~> 1.0) rubyzip @@ -297,24 +302,24 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - squeel (1.0.15) + squeel (1.0.17) activerecord (~> 3.0) activesupport (~> 3.0) polyamorous (~> 0.5.0) switch_user (0.6.0) terminal-table (1.4.5) - therubyracer (0.11.3) + therubyracer (0.11.4) libv8 (~> 3.11.8.12) ref thor (0.17.0) - tilt (1.3.3) - tins (0.7.0) + tilt (1.3.4) + tins (0.7.1) treetop (1.4.12) polyglot polyglot (>= 0.3.1) - turbolinks (0.5.2) + turbolinks (1.0.0) coffee-rails - tzinfo (0.3.35) + tzinfo (0.3.36) uglifier (1.3.0) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) @@ -324,7 +329,7 @@ GEM raindrops (~> 0.7) warden (1.2.1) rack (>= 1.0) - webshims-rails (0.4.6) + webshims-rails (0.4.7) rails (> 3.1.0) websocket (1.0.7) xpath (0.1.4) @@ -335,10 +340,10 @@ PLATFORMS DEPENDENCIES active-model-email-validator (~> 1.0.2) - active_scaffold (~> 3.2.16) + active_scaffold (~> 3.2.19) acts_as_nested_interval (~> 0.0.7) audited-activerecord (~> 3.0) - bootstrap-sass (~> 2.1.0.0) + bootstrap-sass (~> 2.2.0) cancan (= 1.6.7) capistrano (~> 2.9.0) capistrano-ext (~> 1.2.1) @@ -346,15 +351,15 @@ DEPENDENCIES coffee-rails (~> 3.2.1) compass-rails (~> 1.0.3) concerned_with (~> 0.1.0) - dalli (~> 1.1.3) + dalli (~> 2.6.2) database_cleaner (~> 0.7.1) devise (~> 2.1.0) factory_girl_rails (~> 1.6.0) faker (~> 1.0.1) - font-awesome-sass-rails (~> 2.0.0.0) + font-awesome-sass-rails (~> 3.0.0) guard-rspec (~> 0.6.0) guard-spork (~> 0.5.1) - jquery-rails + jquery-rails (~> 2.1.3) libnotify (~> 0.7.2) mail_form (~> 1.3.0) mongrel (>= 1.2.0.pre2) @@ -362,10 +367,10 @@ DEPENDENCIES navigasmic (~> 0.5.6)! nilify_blanks (~> 1.0.0) quiet_assets (~> 1.0.1) - rails (= 3.2.11) + rails (= 3.2.12) rails-backbone (~> 0.7.0) rails-settings-cached (~> 0.2.2) - rails_admin (~> 0.0.5) + rails_admin (~> 0.4.5) rails_config (~> 0.2.4) rb-inotify (~> 0.8.8) rspec-rails (~> 2.10.1) @@ -379,9 +384,9 @@ DEPENDENCIES squeel (~> 1.0.0) switch_user (~> 0.6.0) therubyracer - turbolinks (~> 0.5.1) + turbolinks (~> 1.0.0) uglifier (>= 1.0.3) unicorn (~> 4.5.0) userstamp (~> 2.0.2)! validates_hostname (~> 1.0.0)! - webshims-rails (~> 0.2) + webshims-rails (~> 0.4.7) diff --git a/app/models/audit.rb b/app/models/audit.rb new file mode 100644 index 0000000..a33b1f3 --- /dev/null +++ b/app/models/audit.rb @@ -0,0 +1,5 @@ +class Audit < Audited::Adapters::ActiveRecord::Audit + before_save do + self.username = user.full_name if !username && user + end +end \ No newline at end of file diff --git a/app/models/domain.rb b/app/models/domain.rb index 1ffd3c2..11a4d0c 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -14,6 +14,7 @@ class Domain < ActiveRecord::Base has_many :records, :inverse_of => :domain, :dependent => :destroy has_many :permissions, :inverse_of => :domain, :dependent => :destroy has_many :permitted_users, :through => :permissions, :source => :user + has_many :audits, :as => :auditable cattr_reader :types @@types = ['NATIVE', 'MASTER', 'SLAVE', 'SUPERSLAVE'] diff --git a/app/models/permission.rb b/app/models/permission.rb index 0edb89a..d1863b6 100644 --- a/app/models/permission.rb +++ b/app/models/permission.rb @@ -4,6 +4,7 @@ class Permission < ActiveRecord::Base belongs_to :domain, :inverse_of => :permissions belongs_to :user, :inverse_of => :permissions + has_many :audits, :as => :auditable validates :domain_id, :presence => true validates :user_id, :presence => true, :uniqueness => { diff --git a/app/models/record.rb b/app/models/record.rb index dddfcd0..ac76b5e 100644 --- a/app/models/record.rb +++ b/app/models/record.rb @@ -4,6 +4,7 @@ class Record < ActiveRecord::Base belongs_to :domain, :inverse_of => :records belongs_to :user, :inverse_of => :records + has_many :audits, :as => :auditable cattr_reader :types @@types = %w(SOA NS A MX TXT CNAME AAAA SRV) diff --git a/app/models/user.rb b/app/models/user.rb index 93205fd..c83898c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,6 +25,7 @@ class User < ActiveRecord::Base has_many :records, :inverse_of => :user, :dependent => :destroy has_many :permissions, :inverse_of => :user, :dependent => :destroy has_many :permitted_domains, :through => :permissions, :source => :domain + has_many :audits, :as => :auditable def name full_name.blank? ? email : full_name diff --git a/config/initializers/audited.rb b/config/initializers/audited.rb new file mode 100644 index 0000000..b230d37 --- /dev/null +++ b/config/initializers/audited.rb @@ -0,0 +1 @@ +Audited.audit_class = Audit \ No newline at end of file diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index d8216fe..c87ec71 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -35,7 +35,7 @@ RailsAdmin.config do |config| # Add models here if you want to go 'whitelist mode': config.included_models = [A, AAAA, Admin, CNAME, Domain, MX, NS, Permission, - Record, SOA, SRV, TXT, User, Audited::Adapters::ActiveRecord::Audit] + Record, SOA, SRV, TXT, User, Audit] # Application wide tried label methods for models' instances # config.label_methods << :description # Default is [:name, :title] @@ -84,6 +84,19 @@ RailsAdmin.config do |config| configure :value, :text end + config.model Audit do + field :id + field :user + field :username + field :auditable + field :action + field :audited_changes + field :version + field :comment + field :remote_address + field :created_at + end + # config.model A do # # Found associations: # configure :domain, :belongs_to_association diff --git a/db/seeds/development/domains.seeds.rb b/db/seeds/development/domains.seeds.rb index 0fbcde9..eb907a8 100644 --- a/db/seeds/development/domains.seeds.rb +++ b/db/seeds/development/domains.seeds.rb @@ -2,15 +2,17 @@ after 'development:users' do entrydns_org = Domain.find_by_name(Settings.host_domains.first) User.all.each do |user| - 3.times do - domain = Factory.build(:domain, :user => user) - domain.setup(FactoryGirl.generate(:email)) - domain.save! - domain.soa_record.update_serial! - end + Audit.as_user(user) do + 3.times do + domain = Factory.build(:domain, :user => user) + domain.setup(FactoryGirl.generate(:email)) + domain.save! + domain.soa_record.update_serial! + end - 50.times do - Factory.create(:a, :user => user, :domain => entrydns_org) + 50.times do + Factory.create(:a, :user => user, :domain => entrydns_org) + end end end