From 638708226857c1025d699779a402099a2c7f914d Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Sat, 21 Apr 2012 15:31:10 +0300 Subject: [PATCH] delete restrict, fix tree nesting, deps update --- Gemfile | 4 +- Gemfile.lock | 75 +++++++++++++-------------- app/controllers/domains_controller.rb | 15 ++++++ app/helpers/domains_helper.rb | 2 +- app/models/domain/tree_structure.rb | 11 ++-- 5 files changed, 61 insertions(+), 46 deletions(-) diff --git a/Gemfile b/Gemfile index 5f52270..45bdb79 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'userstamp_basic', '~> 0.1.0' gem 'active_scaffold', '~> 3.2.3' # git: 'https://github.com/activescaffold/active_scaffold.git' # path: '/home/clyfe/dev/active_scaffold' -gem 'pjax_rails', '~> 0.1.7', git: 'https://github.com/rails/pjax_rails.git' +gem 'pjax_rails', '~> 0.2.0' gem 'validates_hostname', '~> 1.0.0', git: 'https://github.com/KimNorgaard/validates_hostname.git' gem 'nilify_blanks', '~> 1.0.0' gem 'rails_config', '~> 0.2.4' @@ -27,7 +27,7 @@ gem 'simple_form', '~> 2.0.0' gem 'concerned_with', '~> 0.1.0' gem 'navigasmic', '~> 0.5.6', git: 'https://github.com/jejacks0n/navigasmic.git' gem 'rails-backbone', '~> 0.7.0' -gem 'acts_as_nested_interval', '~> 0.0.2' +gem 'acts_as_nested_interval', '~> 0.0.5' # path: '/home/clyfe/dev/acts_as_nested_interval' # git: 'https://github.com/clyfe/acts_as_nested_interval.git' diff --git a/Gemfile.lock b/Gemfile.lock index fc31a2c..398b6b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,17 +6,10 @@ GIT GIT remote: https://github.com/jejacks0n/navigasmic.git - revision: 6108afe7930fd4b3282cbe8942240bf4f70e2f74 + revision: 28b18a66ad0aedcf0582df317612d6021e78858b specs: navigasmic (0.5.6) -GIT - remote: https://github.com/rails/pjax_rails.git - revision: e79a1cf58a8935eb132f4910f300cf86d081ae6d - specs: - pjax_rails (0.1.7) - jquery-rails - GEM remote: http://rubygems.org/ specs: @@ -52,8 +45,9 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_nested_interval (0.0.2) + acts_as_nested_interval (0.0.5) rails (~> 3.2.1) + addressable (2.2.7) arel (3.0.2) bcrypt-ruby (3.0.1) bootstrap-sass-rails (2.0.0.3) @@ -76,7 +70,7 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.1) + childprocess (0.3.2) ffi (~> 1.0.6) chunky_png (1.2.5) coffee-rails (3.2.2) @@ -85,17 +79,17 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) - compass (0.12.rc.1) + coffee-script-source (1.3.1) + compass (0.12.1) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.0.rc.3) - compass (~> 0.12.rc.0) + compass-rails (1.0.1) + compass (~> 0.12.0) concerned_with (0.1.0) daemons (1.0.10) dalli (1.1.5) - database_cleaner (0.7.1) + database_cleaner (0.7.2) devise (2.0.4) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) @@ -116,7 +110,7 @@ GEM ffi (1.0.11) file-tail (1.0.8) tins (~> 0.3) - fssm (0.2.8.1) + fssm (0.2.9) gem_plugin (0.2.3) guard (1.0.1) ffi (>= 0.5.0) @@ -130,22 +124,24 @@ GEM hike (1.2.1) i18n (0.6.0) journey (1.0.3) - jquery-rails (2.0.1) + jquery-rails (2.0.2) railties (>= 3.2.0, < 5.0) thor (~> 0.14) - json (1.6.5) + json (1.6.6) libnotify (0.7.2) libv8 (3.3.10.4) - mail (2.4.3) + libwebsocket (0.1.3) + addressable + mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mail_form (1.3.0) - mime-types (1.17.2) + mime-types (1.18) mongrel (1.2.0.pre2) daemons (~> 1.0.10) gem_plugin (~> 0.2.3) - multi_json (1.1.0) + multi_json (1.3.2) mysql2 (0.3.11) net-scp (1.0.4) net-ssh (>= 1.99.1) @@ -157,8 +153,10 @@ GEM nilify_blanks (1.0.0) activerecord (>= 3.0.0) activesupport (>= 3.0.0) - nokogiri (1.5.0) - orm_adapter (0.0.6) + nokogiri (1.5.2) + orm_adapter (0.0.7) + pjax_rails (0.2.0) + jquery-rails polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) @@ -177,11 +175,11 @@ GEM activesupport (= 3.2.2) bundler (~> 1.0) railties (= 3.2.2) - rails-backbone (0.7.0) + rails-backbone (0.7.2) coffee-script (~> 2.2.0) ejs (~> 1.0.0) railties (>= 3.1.0) - rails_config (0.2.5) + rails_config (0.2.7) activesupport (>= 3.0) railties (3.2.2) actionpack (= 3.2.2) @@ -213,24 +211,25 @@ GEM sexp_processor (~> 3.0) ruby_parser (2.3.1) sexp_processor (~> 3.0) - rubyzip (0.9.6.1) - sass (3.1.15) - sass-rails (3.2.4) + rubyzip (0.9.7) + sass (3.1.16) + sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - selenium-webdriver (2.20.0) + selenium-webdriver (2.21.2) childprocess (>= 0.2.5) ffi (~> 1.0) + libwebsocket (~> 0.1.3) multi_json (~> 1.0) rubyzip sentient_user (0.3.2) - sexp_processor (3.1.0) + sexp_processor (3.2.0) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - simplecov (0.6.1) - multi_json (~> 1.0) + simplecov (0.6.2) + multi_json (~> 1.3) simplecov-html (~> 0.5.3) simplecov-html (0.5.3) sourcify (0.6.0.rc1) @@ -248,16 +247,16 @@ GEM activesupport (~> 3.0) polyamorous (~> 0.5.0) switch_user (0.6.0) - therubyracer (0.9.10) + therubyracer (0.10.1) libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) - tins (0.3.9) + tins (0.3.13) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) - uglifier (1.2.3) + tzinfo (0.3.33) + uglifier (1.2.4) execjs (>= 0.3.0) multi_json (>= 1.0.2) userstamp_basic (0.1.0) @@ -273,7 +272,7 @@ PLATFORMS DEPENDENCIES active-model-email-validator (~> 1.0.2) active_scaffold (~> 3.2.3) - acts_as_nested_interval (~> 0.0.2) + acts_as_nested_interval (~> 0.0.5) bootstrap-sass-rails (~> 2.0.0.2) cancan (~> 1.6.7) capistrano (~> 2.9.0) @@ -296,7 +295,7 @@ DEPENDENCIES mysql2 navigasmic (~> 0.5.6)! nilify_blanks (~> 1.0.0) - pjax_rails (~> 0.1.7)! + pjax_rails (~> 0.2.0) rails (= 3.2.2) rails-backbone (~> 0.7.0) rails_config (~> 0.2.4) diff --git a/app/controllers/domains_controller.rb b/app/controllers/domains_controller.rb index 769ff53..ced9fd7 100644 --- a/app/controllers/domains_controller.rb +++ b/app/controllers/domains_controller.rb @@ -39,6 +39,21 @@ class DomainsController < ApplicationController end end + def do_destroy + @record ||= destroy_find_record + begin + self.successful = @record.destroy + marked_records.delete @record.id.to_s if successful? + rescue ActiveRecord::DeleteRestrictionError => e + flash[:warning] = as_(:cant_destroy_record, :record => @record.to_label) + @record.errors.add :base, "Delete subdomains first" + self.successful = false + rescue + flash[:warning] = as_(:cant_destroy_record, :record => @record.to_label) + self.successful = false + end + end + def new_model record = super before_create_save(record) diff --git a/app/helpers/domains_helper.rb b/app/helpers/domains_helper.rb index b7c2056..76472b2 100644 --- a/app/helpers/domains_helper.rb +++ b/app/helpers/domains_helper.rb @@ -10,7 +10,7 @@ module DomainsHelper def domain_name_column(record) elements = [] depth = record.depth - if depth > 1 && @previous_record && record.subdomain_of?(@previous_record) + if depth > 1 (depth - 2).times do # indent elements << '' end diff --git a/app/models/domain/tree_structure.rb b/app/models/domain/tree_structure.rb index 9851ec3..3bea0a5 100644 --- a/app/models/domain/tree_structure.rb +++ b/app/models/domain/tree_structure.rb @@ -47,9 +47,10 @@ class Domain < ActiveRecord::Base name.end_with?('.' + domain.name) end - # Overrides acts_as_nested_interval#ancestor_of? - def ancestor_of?(domain) - domain.subdomain_of?(self) + def self.rebuild_nested_interval_tree! + skip_callback :update, :before, :sync_children + super + set_callback :update, :before, :sync_children end protected @@ -72,7 +73,7 @@ class Domain < ActiveRecord::Base self.parent = parent_domain end end - + # Syncs with nested interval when the parent is added later than the children def sync_children descendants = subdomains.preorder.all @@ -90,4 +91,4 @@ class Domain < ActiveRecord::Base end end -end \ No newline at end of file +end