Browse Source

fix when domain ownership validation fails, for inputs are not reshown

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
b00ae074d9
  1. 4
      app/assets/stylesheets/overrides.css.scss
  2. 7
      app/controllers/domains_controller.rb
  3. 4
      app/models/domain.rb

4
app/assets/stylesheets/overrides.css.scss

@ -16,4 +16,8 @@
a.as_cancel {
vertical-align: middle;
}
.active-scaffold ol {
display: table;
margin-left: 0;
}
}

7
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)

4
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

Loading…
Cancel
Save