From b00ae074d99135984230d9f2487095f7667f7267 Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Sun, 26 Feb 2012 02:07:40 -0800 Subject: [PATCH] fix when domain ownership validation fails, for inputs are not reshown --- app/assets/stylesheets/overrides.css.scss | 4 ++++ app/controllers/domains_controller.rb | 7 +++++++ app/models/domain.rb | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/overrides.css.scss b/app/assets/stylesheets/overrides.css.scss index cc849b8..f54315f 100644 --- a/app/assets/stylesheets/overrides.css.scss +++ b/app/assets/stylesheets/overrides.css.scss @@ -16,4 +16,8 @@ a.as_cancel { vertical-align: middle; } + .active-scaffold ol { + display: table; + margin-left: 0; + } } diff --git a/app/controllers/domains_controller.rb b/app/controllers/domains_controller.rb index 9606197..587998b 100644 --- a/app/controllers/domains_controller.rb +++ b/app/controllers/domains_controller.rb @@ -26,6 +26,13 @@ class DomainsController < ApplicationController @record.setup(current_user.email) end + def do_create + super + if !successful? && @record.domain_ownership_failed + @record.user = current_user + end + end + def new_model record = super before_create_save(record) diff --git a/app/models/domain.rb b/app/models/domain.rb index f237ef2..b455b69 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -5,6 +5,7 @@ class Domain < ActiveRecord::Base # optional IP for create form, results in a type A record attr_accessor :ip + attr_accessor :domain_ownership_failed belongs_to :user, :inverse_of => :domain has_many :records, :inverse_of => :domain, :dependent => :destroy @@ -54,7 +55,8 @@ class Domain < ActiveRecord::Base # If parent domain is on our system, the user be permitted to manage current domain. # He either owns parent, or is permitted to current domain or to an ancestor. - if parent_domain.present? && can_be_managed_by_current_user? + if parent_domain.present? && !parent_domain.can_be_managed_by_current_user? + @domain_ownership_failed = true errors[:name] = "issue, the parent domain `#{parent_domain.name}` is registered to another user" end end