mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
88d1b46094
19 changed files with 313 additions and 300 deletions
|
@ -16,13 +16,13 @@ class Admin::DomainsController < AdminController
|
|||
end
|
||||
|
||||
def update
|
||||
add_prefix_to_statuses
|
||||
dp = ignore_empty_statuses
|
||||
|
||||
if @domain.update(domain_params)
|
||||
if @domain.update(dp)
|
||||
flash[:notice] = I18n.t('domain_updated')
|
||||
redirect_to [:admin, @domain]
|
||||
else
|
||||
@domain.domain_statuses.build if @domain.domain_statuses.empty?
|
||||
build_associations
|
||||
flash.now[:alert] = I18n.t('failed_to_update_domain')
|
||||
render 'edit'
|
||||
end
|
||||
|
@ -53,21 +53,23 @@ class Admin::DomainsController < AdminController
|
|||
end
|
||||
|
||||
def domain_params
|
||||
params.require(:domain).permit(
|
||||
domain_statuses_attributes: [:id, :value, :description, :_destroy]
|
||||
)
|
||||
if params[:domain]
|
||||
params.require(:domain).permit({ statuses: [] })
|
||||
else
|
||||
{statuses: []}
|
||||
end
|
||||
end
|
||||
|
||||
def build_associations
|
||||
@domain.domain_statuses.build if @domain.domain_statuses.empty?
|
||||
@server_statuses = @domain.domain_statuses.select(&:server_status?)
|
||||
@server_statuses << @domain.domain_statuses.build if @server_statuses.empty?
|
||||
@server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) }
|
||||
@server_statuses = [nil] if @server_statuses.empty?
|
||||
@other_statuses = @domain.statuses.select { |x| !DomainStatus::SERVER_STATUSES.include?(x) }
|
||||
end
|
||||
|
||||
def add_prefix_to_statuses
|
||||
domain_params[:domain_statuses_attributes].each do |_k, hash|
|
||||
hash[:value] = hash[:value].prepend('server') if hash[:value].present?
|
||||
end
|
||||
def ignore_empty_statuses
|
||||
dp = domain_params
|
||||
dp[:statuses].reject! { |x| x.blank? }
|
||||
dp
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ class AdminUser < User
|
|||
validates :username, :country_code, :roles, presence: true
|
||||
validates :identity_code, uniqueness: true, allow_blank: true
|
||||
validates :identity_code, presence: true, if: -> { country_code == 'EE' }
|
||||
validates :email, presence: true
|
||||
validates :email, presence: true
|
||||
validates :password, :password_confirmation, presence: true, if: :new_record?
|
||||
validates :password_confirmation, presence: true, if: :encrypted_password_changed?
|
||||
validate :validate_identity_code, if: -> { country_code == 'EE' }
|
||||
|
|
|
@ -68,13 +68,16 @@ class Domain < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
before_save :manage_automatic_statuses
|
||||
|
||||
before_save :touch_always_version
|
||||
def touch_always_version
|
||||
self.updated_at = Time.zone.now
|
||||
end
|
||||
after_save :manage_automatic_statuses
|
||||
after_save :update_whois_record
|
||||
|
||||
after_initialize -> { self.statuses = [] if statuses.nil? }
|
||||
|
||||
validates :name_dirty, domain_name: true, uniqueness: true
|
||||
validates :puny_label, length: { maximum: 63 }
|
||||
validates :period, numericality: { only_integer: true }
|
||||
|
@ -124,6 +127,12 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
validate :validate_nameserver_ips
|
||||
|
||||
validate :statuses_uniqueness
|
||||
def statuses_uniqueness
|
||||
return if statuses.uniq == statuses
|
||||
errors.add(:statuses, :taken)
|
||||
end
|
||||
|
||||
attr_accessor :registrant_typeahead, :update_me, :deliver_emails,
|
||||
:epp_pending_update, :epp_pending_delete
|
||||
|
||||
|
@ -159,9 +168,10 @@ class Domain < ActiveRecord::Base
|
|||
d = Domain.where('valid_to <= ?', Time.zone.now)
|
||||
d.each do |x|
|
||||
next unless x.expirable?
|
||||
x.domain_statuses.create(value: DomainStatus::EXPIRED)
|
||||
x.statuses << DomainStatus::EXPIRED
|
||||
# TODO: This should be managed by automatic_statuses
|
||||
x.domain_statuses.where(value: DomainStatus::OK).destroy_all
|
||||
x.statuses.delete(DomainStatus::OK)
|
||||
x.save(validate: false)
|
||||
end
|
||||
|
||||
STDOUT << "#{Time.zone.now.utc} - Successfully expired #{d.count} domains\n" unless Rails.env.test?
|
||||
|
@ -173,9 +183,10 @@ class Domain < ActiveRecord::Base
|
|||
d = Domain.where('outzone_at <= ?', Time.zone.now)
|
||||
d.each do |x|
|
||||
next unless x.server_holdable?
|
||||
x.domain_statuses.create(value: DomainStatus::SERVER_HOLD)
|
||||
x.statuses << DomainStatus::SERVER_HOLD
|
||||
# TODO: This should be managed by automatic_statuses
|
||||
x.domain_statuses.where(value: DomainStatus::OK).destroy_all
|
||||
x.statuses.delete(DomainStatus::OK)
|
||||
x.save
|
||||
end
|
||||
|
||||
STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test?
|
||||
|
@ -186,9 +197,10 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
d = Domain.where('delete_at <= ?', Time.zone.now)
|
||||
d.each do |x|
|
||||
x.domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if x.delete_candidateable?
|
||||
x.statuses << DomainStatus::DELETE_CANDIDATE if x.delete_candidateable?
|
||||
# TODO: This should be managed by automatic_statuses
|
||||
x.domain_statuses.where(value: DomainStatus::OK).destroy_all
|
||||
x.statuses.delete(DomainStatus::OK)
|
||||
x.save
|
||||
end
|
||||
|
||||
return if Rails.env.test?
|
||||
|
@ -199,8 +211,8 @@ class Domain < ActiveRecord::Base
|
|||
STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test?
|
||||
|
||||
c = 0
|
||||
DomainStatus.where(value: DomainStatus::DELETE_CANDIDATE).each do |x|
|
||||
x.domain.destroy
|
||||
Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x|
|
||||
x.destroy
|
||||
c += 1
|
||||
end
|
||||
|
||||
|
@ -237,28 +249,22 @@ class Domain < ActiveRecord::Base
|
|||
domain_transfers.find_by(status: DomainTransfer::PENDING)
|
||||
end
|
||||
|
||||
def can_be_deleted?
|
||||
(domain_statuses.pluck(:value) & %W(
|
||||
#{DomainStatus::SERVER_DELETE_PROHIBITED}
|
||||
)).empty?
|
||||
end
|
||||
|
||||
def expirable?
|
||||
return false if valid_to > Time.zone.now
|
||||
domain_statuses.where(value: DomainStatus::EXPIRED).empty?
|
||||
!statuses.include?(DomainStatus::EXPIRED)
|
||||
end
|
||||
|
||||
def server_holdable?
|
||||
return false if outzone_at > Time.zone.now
|
||||
return false if domain_statuses.where(value: DomainStatus::SERVER_HOLD).any?
|
||||
return false if domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).any?
|
||||
return false if statuses.include?(DomainStatus::SERVER_HOLD)
|
||||
return false if statuses.include?(DomainStatus::SERVER_MANUAL_INZONE)
|
||||
true
|
||||
end
|
||||
|
||||
def delete_candidateable?
|
||||
return false if delete_at > Time.zone.now
|
||||
return false if domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).any?
|
||||
return false if domain_statuses.where(value: DomainStatus::SERVER_DELETE_PROHIBITED).any?
|
||||
return false if statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||
return false if statuses.include?(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -269,7 +275,7 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
return false if domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).any?
|
||||
return false if statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||
|
||||
true
|
||||
end
|
||||
|
@ -282,15 +288,13 @@ class Domain < ActiveRecord::Base
|
|||
def clean_pendings!
|
||||
preclean_pendings
|
||||
self.pending_json = {}
|
||||
domain_statuses.where(value: DomainStatus::PENDING_UPDATE).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::PENDING_DELETE).destroy_all
|
||||
statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
statuses.delete(DomainStatus::PENDING_DELETE)
|
||||
save
|
||||
end
|
||||
|
||||
def pending_update?
|
||||
(domain_statuses.pluck(:value) & %W(
|
||||
#{DomainStatus::PENDING_UPDATE}
|
||||
)).present?
|
||||
statuses.include?(DomainStatus::PENDING_UPDATE)
|
||||
end
|
||||
|
||||
def pending_update!
|
||||
|
@ -310,8 +314,8 @@ class Domain < ActiveRecord::Base
|
|||
self.pending_json = pending_json_cache
|
||||
self.registrant_verification_token = token
|
||||
self.registrant_verification_asked_at = asked_at
|
||||
self.statuses = [DomainStatus::PENDING_UPDATE]
|
||||
self.pending_json[:domain] = changes_cache
|
||||
domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
|
||||
end
|
||||
|
||||
def registrant_update_confirmable?(token)
|
||||
|
@ -335,7 +339,7 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def force_deletable?
|
||||
domain_statuses.where(value: DomainStatus::FORCE_DELETE).empty?
|
||||
!statuses.include?(DomainStatus::FORCE_DELETE)
|
||||
end
|
||||
|
||||
def registrant_verification_asked?
|
||||
|
@ -350,9 +354,7 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def pending_delete?
|
||||
(domain_statuses.pluck(:value) & %W(
|
||||
#{DomainStatus::PENDING_DELETE}
|
||||
)).present?
|
||||
statuses.include?(DomainStatus::PENDING_DELETE)
|
||||
end
|
||||
|
||||
def pending_delete!
|
||||
|
@ -360,7 +362,9 @@ class Domain < ActiveRecord::Base
|
|||
self.epp_pending_delete = true # for epp
|
||||
|
||||
return true unless registrant_verification_asked?
|
||||
domain_statuses.create(value: DomainStatus::PENDING_DELETE)
|
||||
statuses = [DomainStatus::PENDING_DELETE]
|
||||
save(validate: false) # should check if this did succeed
|
||||
|
||||
DomainMailer.pending_deleted(self).deliver_now
|
||||
end
|
||||
|
||||
|
@ -440,41 +444,38 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def set_force_delete
|
||||
domain_statuses.where(value: DomainStatus::FORCE_DELETE).first_or_create
|
||||
domain_statuses.where(value: DomainStatus::SERVER_RENEW_PROHIBITED).first_or_create
|
||||
domain_statuses.where(value: DomainStatus::SERVER_TRANSFER_PROHIBITED).first_or_create
|
||||
domain_statuses.where(value: DomainStatus::SERVER_UPDATE_PROHIBITED).first_or_create
|
||||
domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).first_or_create
|
||||
domain_statuses.where(value: DomainStatus::PENDING_DELETE).first_or_create
|
||||
domain_statuses.where(value: DomainStatus::CLIENT_DELETE_PROHIBITED).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::SERVER_DELETE_PROHIBITED).destroy_all
|
||||
domain_statuses.reload
|
||||
statuses << DomainStatus::FORCE_DELETE
|
||||
statuses << DomainStatus::SERVER_RENEW_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
statuses << DomainStatus::SERVER_MANUAL_INZONE
|
||||
statuses << DomainStatus::PENDING_DELETE
|
||||
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
|
||||
self.force_delete_at = Time.zone.now + Setting.redemption_grace_period.days unless force_delete_at
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
def unset_force_delete
|
||||
domain_statuses.where(value: DomainStatus::FORCE_DELETE).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::SERVER_RENEW_PROHIBITED).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::SERVER_TRANSFER_PROHIBITED).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::SERVER_UPDATE_PROHIBITED).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::PENDING_DELETE).destroy_all
|
||||
domain_statuses.reload
|
||||
statuses.delete(DomainStatus::FORCE_DELETE)
|
||||
statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_MANUAL_INZONE)
|
||||
statuses.delete(DomainStatus::PENDING_DELETE)
|
||||
|
||||
self.force_delete_at = nil
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable?
|
||||
if domain_statuses.empty? && valid?
|
||||
domain_statuses.create(value: DomainStatus::OK)
|
||||
elsif domain_statuses.length > 1 || !valid?
|
||||
domain_statuses.find_by(value: DomainStatus::OK).try(:destroy)
|
||||
if statuses.empty? && valid?
|
||||
statuses << DomainStatus::OK
|
||||
elsif statuses.length > 1 || !valid?
|
||||
statuses.delete(DomainStatus::OK)
|
||||
end
|
||||
|
||||
# otherwise domain_statuses are in old state for domain object
|
||||
domain_statuses.reload
|
||||
end
|
||||
|
||||
def children_log
|
||||
|
|
|
@ -124,7 +124,7 @@ class DomainStatus < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def statuses_for_admin
|
||||
SERVER_STATUSES.map { |x| x.sub('server', '') }
|
||||
SERVER_STATUSES.map { |x| [x.sub('server', ''), x] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -110,10 +110,12 @@ class Epp::Domain < Domain
|
|||
|
||||
at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y'
|
||||
|
||||
# at[:statuses] = domain_statuses_attrs(frame, action)
|
||||
# binding.pry
|
||||
at[:nameservers_attributes] = nameservers_attrs(frame, action)
|
||||
at[:admin_domain_contacts_attributes] = admin_domain_contacts_attrs(frame, action)
|
||||
at[:tech_domain_contacts_attributes] = tech_domain_contacts_attrs(frame, action)
|
||||
at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action)
|
||||
# at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action)
|
||||
|
||||
if new_record?
|
||||
dnskey_frame = frame.css('extension create')
|
||||
|
@ -235,24 +237,6 @@ class Epp::Domain < Domain
|
|||
attrs
|
||||
end
|
||||
|
||||
def domain_status_list_from(frame)
|
||||
status_list = []
|
||||
|
||||
frame.css('status').each do |x|
|
||||
unless DomainStatus::CLIENT_STATUSES.include?(x['s'])
|
||||
add_epp_error('2303', 'status', x['s'], [:domain_statuses, :not_found])
|
||||
next
|
||||
end
|
||||
|
||||
status_list << {
|
||||
value: x['s'],
|
||||
description: x.text
|
||||
}
|
||||
end
|
||||
|
||||
status_list
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def dnskeys_attrs(frame, action)
|
||||
|
@ -336,14 +320,10 @@ class Epp::Domain < Domain
|
|||
if action == 'rem'
|
||||
to_destroy = []
|
||||
status_list.each do |x|
|
||||
status = domain_statuses.find_by(value: x[:value])
|
||||
if status.blank?
|
||||
add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found])
|
||||
if statuses.include?(x)
|
||||
to_destroy << x
|
||||
else
|
||||
to_destroy << {
|
||||
id: status.id,
|
||||
_destroy: 1
|
||||
}
|
||||
add_epp_error('2303', 'status', x, [:domain_statuses, :not_found])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -362,10 +342,7 @@ class Epp::Domain < Domain
|
|||
next
|
||||
end
|
||||
|
||||
status_list << {
|
||||
value: x['s'],
|
||||
description: x.text
|
||||
}
|
||||
status_list << x['s']
|
||||
end
|
||||
|
||||
status_list
|
||||
|
@ -392,13 +369,13 @@ class Epp::Domain < Domain
|
|||
at[:admin_domain_contacts_attributes] += at_add[:admin_domain_contacts_attributes]
|
||||
at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes]
|
||||
at[:dnskeys_attributes] += at_add[:dnskeys_attributes]
|
||||
at[:domain_statuses_attributes] += at_add[:domain_statuses_attributes]
|
||||
at[:statuses] = statuses - domain_statuses_attrs(frame.css('rem'), 'rem') + domain_statuses_attrs(frame.css('add'), 'add')
|
||||
# at[:statuses] += at_add[:domain_statuses_attributes]
|
||||
|
||||
if verify && frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes'
|
||||
registrant_verification_asked!(frame.to_s, current_user.id)
|
||||
end
|
||||
self.deliver_emails = true # turn on email delivery for epp
|
||||
|
||||
errors.empty? && super(at)
|
||||
end
|
||||
|
||||
|
@ -406,8 +383,8 @@ class Epp::Domain < Domain
|
|||
preclean_pendings
|
||||
user = ApiUser.find(pending_json['current_user_id'])
|
||||
frame = Nokogiri::XML(pending_json['frame'])
|
||||
domain_statuses.where(value: DomainStatus::PENDING_UPDATE).destroy_all
|
||||
domain_statuses.reload
|
||||
statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
|
||||
if update(frame, user, false)
|
||||
clean_pendings!
|
||||
end
|
||||
|
@ -450,8 +427,8 @@ class Epp::Domain < Domain
|
|||
self.period = period
|
||||
self.period_unit = unit
|
||||
|
||||
domain_statuses.where(value: DomainStatus::SERVER_HOLD).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::EXPIRED).destroy_all
|
||||
statuses.delete(DomainStatus::SERVER_HOLD)
|
||||
statuses.delete(DomainStatus::EXPIRED)
|
||||
|
||||
save
|
||||
end
|
||||
|
@ -693,9 +670,7 @@ class Epp::Domain < Domain
|
|||
begin
|
||||
errors.add(:base, :domain_status_prohibits_operation)
|
||||
return false
|
||||
end if (domain_statuses.pluck(:value) & %W(
|
||||
#{DomainStatus::CLIENT_DELETE_PROHIBITED}
|
||||
)).any?
|
||||
end if statuses.include?(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -20,11 +20,11 @@ class WhoisRecord < ActiveRecord::Base
|
|||
includes(
|
||||
domain: [
|
||||
:registrant,
|
||||
:registrar,
|
||||
:nameservers,
|
||||
:registrar,
|
||||
:nameservers,
|
||||
{ tech_contacts: :registrar },
|
||||
{ admin_contacts: :registrar }
|
||||
]
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -34,19 +34,23 @@ class WhoisRecord < ActiveRecord::Base
|
|||
h = HashWithIndifferentAccess.new
|
||||
return h if domain.blank?
|
||||
|
||||
status_map = {
|
||||
'ok' => 'ok (paid and in zone)'
|
||||
}
|
||||
|
||||
@disclosed = []
|
||||
h[:name] = domain.name
|
||||
h[:registrant] = domain.registrant.name
|
||||
h[:status] = domain.domain_statuses.map(&:human_value).join(', ')
|
||||
h[:status] = domain.statuses.map { |x| status_map[x] || x }.join(', ')
|
||||
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
||||
h[:updated_at] = domain.updated_at.try(:to_s, :iso8601)
|
||||
h[:valid_to] = domain.valid_to.try(:to_s, :iso8601)
|
||||
|
||||
|
||||
# update registar triggers when adding new attributes
|
||||
h[:registrar] = domain.registrar.name
|
||||
h[:registrar_phone] = domain.registrar.phone
|
||||
h[:registrar_address] = domain.registrar.address
|
||||
h[:registrar_update_at] = domain.registrar.updated_at.try(:to_s, :iso8601)
|
||||
h[:registrar_update_at] = domain.registrar.updated_at.try(:to_s, :iso8601)
|
||||
|
||||
h[:admin_contacts] = []
|
||||
domain.admin_contacts.each do |ac|
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
#domain-statuses
|
||||
= f.fields_for :domain_statuses, @server_statuses do |status_fields|
|
||||
- @server_statuses.each do |x|
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
.pull-left= t(:status)
|
||||
.pull-right
|
||||
= link_to(t(:add_another), '#', class: 'btn btn-primary btn-xs add-domain-status')
|
||||
= link_to(t(:delete), '#', class: 'btn btn-danger btn-xs destroy')
|
||||
= link_to(t(:delete), '#', class: 'btn btn-danger btn-xs destroy-status')
|
||||
.panel-body
|
||||
.errors
|
||||
= render 'shared/errors', object: status_fields.object
|
||||
- if status_fields.object.errors.any?
|
||||
%hr
|
||||
.form-group
|
||||
= status_fields.label :value, class: 'col-md-2 control-label'
|
||||
= f.label 'status', class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= status_fields.select :value, options_for_select(DomainStatus.statuses_for_admin, status_fields.object.value.try(:sub, 'server', '')), {include_blank: true}, {class: 'form-control'}
|
||||
= select_tag 'domain[statuses][]', options_for_select(DomainStatus.statuses_for_admin, x), include_blank: true, class: 'form-control'
|
||||
.form-group
|
||||
= status_fields.label :description, class: 'col-md-2 control-label'
|
||||
= label_tag t(:description), nil, class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
= status_fields.text_field :description, class: 'form-control', autocomplete: 'off'
|
||||
= text_field_tag :description, nil, class: 'form-control', autocomplete: 'off'
|
||||
- @other_statuses.each do |x|
|
||||
= hidden_field_tag 'domain[statuses][]', x, readonly: true
|
||||
:coffee
|
||||
$("#domain-statuses").nestedAttributes
|
||||
bindAddTo: $(".add-domain-status")
|
||||
afterAdd: (item) ->
|
||||
item.find(".errors").html ""
|
||||
|
||||
$('.destroy-status').on 'click', (e) ->
|
||||
e.preventDefault()
|
||||
if $('.panel').length > 1
|
||||
$(this).parents('.panel').remove()
|
||||
else
|
||||
$(this).parents('.panel').find('select').val('')
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
- panel_class = @domain.errors.messages[:domain_statuses] ? 'panel-danger' : 'panel-default'
|
||||
#domain_statuses.panel{class: panel_class}
|
||||
#domain_statuses.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t(:statuses)
|
||||
.table-responsive
|
||||
|
@ -9,12 +8,7 @@
|
|||
%th{class: 'col-xs-6'}= t(:status)
|
||||
%th{class: 'col-xs-6'}= t(:description)
|
||||
%tbody
|
||||
- @domain.domain_statuses.each do |x|
|
||||
- @domain.statuses.each do |x|
|
||||
%tr
|
||||
%td= x.value
|
||||
%td= x.description
|
||||
- if @domain.errors.messages[:domain_statuses]
|
||||
%tfoot
|
||||
- @domain.errors.messages[:domain_statuses].each do |x|
|
||||
%tr
|
||||
%td{colspan: 4}= x
|
||||
%td= x
|
||||
%td
|
||||
|
|
|
@ -8,9 +8,8 @@ xml.epp_head do
|
|||
xml.tag!('domain:infData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||
xml.tag!('domain:name', @domain.name)
|
||||
xml.tag!('domain:roid', @domain.roid)
|
||||
@domain.domain_statuses.each do |ds|
|
||||
xml.tag!('domain:status', ds.description, 's' => ds.value) unless ds.description.blank?
|
||||
xml.tag!('domain:status', 's' => ds.value) if ds.description.blank?
|
||||
@domain.statuses.each do |s|
|
||||
xml.tag!('domain:status', 's' => s)
|
||||
end
|
||||
|
||||
xml.tag!('domain:registrant', @domain.registrant_code)
|
||||
|
|
|
@ -100,6 +100,8 @@ en:
|
|||
invalid: 'Statuses are invalid'
|
||||
not_found: 'Status was not found'
|
||||
taken: 'Status already exists on this domain'
|
||||
statuses:
|
||||
taken: 'Status already exists on this domain'
|
||||
registrar:
|
||||
blank: 'Registrar is missing'
|
||||
dnskeys:
|
||||
|
|
15
db/data/20150612125720_refactor_domain_statuses.rb
Normal file
15
db/data/20150612125720_refactor_domain_statuses.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class RefactorDomainStatuses < ActiveRecord::Migration
|
||||
def self.up
|
||||
Domain.all.each do |x|
|
||||
x.statuses = []
|
||||
x.domain_statuses.each do |ds|
|
||||
x.statuses << ds.value
|
||||
end
|
||||
x.save
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
5
db/migrate/20150612123111_add_statuses_to_domain.rb
Normal file
5
db/migrate/20150612123111_add_statuses_to_domain.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddStatusesToDomain < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :domains, :statuses, :string, array: true
|
||||
end
|
||||
end
|
43
db/schema.rb
43
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150611124920) do
|
||||
ActiveRecord::Schema.define(version: 20150612123111) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -19,7 +19,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
create_table "account_activities", force: :cascade do |t|
|
||||
t.integer "account_id"
|
||||
t.integer "invoice_id"
|
||||
t.decimal "sum", precision: 10, scale: 2
|
||||
t.decimal "sum", precision: 8, scale: 2
|
||||
t.string "currency"
|
||||
t.integer "bank_transaction_id"
|
||||
t.datetime "created_at"
|
||||
|
@ -36,7 +36,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
create_table "accounts", force: :cascade do |t|
|
||||
t.integer "registrar_id"
|
||||
t.string "account_type"
|
||||
t.decimal "balance", precision: 10, scale: 2, default: 0.0, null: false
|
||||
t.decimal "balance", precision: 8, scale: 2, default: 0.0, null: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "currency"
|
||||
|
@ -98,7 +98,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
t.string "buyer_name"
|
||||
t.string "document_no"
|
||||
t.string "description"
|
||||
t.decimal "sum", precision: 10, scale: 2
|
||||
t.decimal "sum", precision: 8, scale: 2
|
||||
t.string "reference_no"
|
||||
t.datetime "paid_at"
|
||||
t.datetime "created_at"
|
||||
|
@ -114,7 +114,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
t.string "vk_rec_id"
|
||||
t.string "vk_stamp"
|
||||
t.string "vk_t_no"
|
||||
t.decimal "vk_amount", precision: 10, scale: 2
|
||||
t.decimal "vk_amount", precision: 8, scale: 2
|
||||
t.string "vk_curr"
|
||||
t.string "vk_rec_acc"
|
||||
t.string "vk_rec_name"
|
||||
|
@ -203,6 +203,12 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
t.string "updator_str"
|
||||
end
|
||||
|
||||
create_table "data_migrations", id: false, force: :cascade do |t|
|
||||
t.string "version", null: false
|
||||
end
|
||||
|
||||
add_index "data_migrations", ["version"], name: "unique_data_migrations", unique: true, using: :btree
|
||||
|
||||
create_table "delegation_signers", force: :cascade do |t|
|
||||
t.integer "domain_id"
|
||||
t.string "key_tag"
|
||||
|
@ -307,6 +313,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
t.string "registrant_verification_token"
|
||||
t.json "pending_json"
|
||||
t.datetime "force_delete_at"
|
||||
t.string "statuses", array: true
|
||||
end
|
||||
|
||||
add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree
|
||||
|
@ -329,10 +336,10 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
|
||||
create_table "invoice_items", force: :cascade do |t|
|
||||
t.integer "invoice_id"
|
||||
t.string "description", null: false
|
||||
t.string "description", null: false
|
||||
t.string "unit"
|
||||
t.integer "amount"
|
||||
t.decimal "price", precision: 10, scale: 2
|
||||
t.decimal "price", precision: 8, scale: 2
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "creator_str"
|
||||
|
@ -342,20 +349,20 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
add_index "invoice_items", ["invoice_id"], name: "index_invoice_items_on_invoice_id", using: :btree
|
||||
|
||||
create_table "invoices", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "invoice_type", null: false
|
||||
t.datetime "due_date", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "invoice_type", null: false
|
||||
t.datetime "due_date", null: false
|
||||
t.string "payment_term"
|
||||
t.string "currency", null: false
|
||||
t.string "currency", null: false
|
||||
t.string "description"
|
||||
t.string "reference_no"
|
||||
t.decimal "vat_prc", precision: 10, scale: 2, null: false
|
||||
t.decimal "vat_prc", precision: 8, scale: 2, null: false
|
||||
t.datetime "paid_at"
|
||||
t.integer "seller_id"
|
||||
t.string "seller_name", null: false
|
||||
t.string "seller_name", null: false
|
||||
t.string "seller_reg_no"
|
||||
t.string "seller_iban", null: false
|
||||
t.string "seller_iban", null: false
|
||||
t.string "seller_bank"
|
||||
t.string "seller_swift"
|
||||
t.string "seller_vat_no"
|
||||
|
@ -369,7 +376,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
t.string "seller_email"
|
||||
t.string "seller_contact_name"
|
||||
t.integer "buyer_id"
|
||||
t.string "buyer_name", null: false
|
||||
t.string "buyer_name", null: false
|
||||
t.string "buyer_reg_no"
|
||||
t.string "buyer_country_code"
|
||||
t.string "buyer_state"
|
||||
|
@ -383,7 +390,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
t.string "updator_str"
|
||||
t.integer "number"
|
||||
t.datetime "cancelled_at"
|
||||
t.decimal "sum_cache", precision: 10, scale: 2
|
||||
t.decimal "sum_cache", precision: 8, scale: 2
|
||||
end
|
||||
|
||||
add_index "invoices", ["buyer_id"], name: "index_invoices_on_buyer_id", using: :btree
|
||||
|
@ -995,7 +1002,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
|
|||
t.text "crt"
|
||||
t.string "type"
|
||||
t.string "registrant_ident"
|
||||
t.string "encrypted_password", default: ""
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "failed_attempts", default: 0, null: false
|
||||
t.datetime "locked_at"
|
||||
|
|
|
@ -41,7 +41,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
|
|||
ret text;
|
||||
BEGIN
|
||||
-- define filters
|
||||
include_filter = '%' || i_origin;
|
||||
include_filter = '%.' || i_origin;
|
||||
|
||||
-- for %.%.%
|
||||
IF i_origin ~ '\.' THEN
|
||||
|
@ -198,7 +198,7 @@ CREATE TABLE account_activities (
|
|||
id integer NOT NULL,
|
||||
account_id integer,
|
||||
invoice_id integer,
|
||||
sum numeric(10,2),
|
||||
sum numeric(8,2),
|
||||
currency character varying,
|
||||
bank_transaction_id integer,
|
||||
created_at timestamp without time zone,
|
||||
|
@ -236,7 +236,7 @@ CREATE TABLE accounts (
|
|||
id integer NOT NULL,
|
||||
registrar_id integer,
|
||||
account_type character varying,
|
||||
balance numeric(10,2) DEFAULT 0 NOT NULL,
|
||||
balance numeric(8,2) DEFAULT 0.0 NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
currency character varying,
|
||||
|
@ -394,7 +394,7 @@ CREATE TABLE bank_transactions (
|
|||
buyer_name character varying,
|
||||
document_no character varying,
|
||||
description character varying,
|
||||
sum numeric(10,2),
|
||||
sum numeric(8,2),
|
||||
reference_no character varying,
|
||||
paid_at timestamp without time zone,
|
||||
created_at timestamp without time zone,
|
||||
|
@ -435,7 +435,7 @@ CREATE TABLE banklink_transactions (
|
|||
vk_rec_id character varying,
|
||||
vk_stamp character varying,
|
||||
vk_t_no character varying,
|
||||
vk_amount numeric(10,2),
|
||||
vk_amount numeric(8,2),
|
||||
vk_curr character varying,
|
||||
vk_rec_acc character varying,
|
||||
vk_rec_name character varying,
|
||||
|
@ -639,6 +639,15 @@ CREATE SEQUENCE countries_id_seq
|
|||
ALTER SEQUENCE countries_id_seq OWNED BY countries.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE data_migrations (
|
||||
version character varying NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: delegation_signers; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
@ -884,7 +893,8 @@ CREATE TABLE domains (
|
|||
registrant_verification_asked_at timestamp without time zone,
|
||||
registrant_verification_token character varying,
|
||||
pending_json json,
|
||||
force_delete_at timestamp without time zone
|
||||
force_delete_at timestamp without time zone,
|
||||
statuses character varying[]
|
||||
);
|
||||
|
||||
|
||||
|
@ -950,7 +960,7 @@ CREATE TABLE invoice_items (
|
|||
description character varying NOT NULL,
|
||||
unit character varying,
|
||||
amount integer,
|
||||
price numeric(10,2),
|
||||
price numeric(8,2),
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
creator_str character varying,
|
||||
|
@ -991,7 +1001,7 @@ CREATE TABLE invoices (
|
|||
currency character varying NOT NULL,
|
||||
description character varying,
|
||||
reference_no character varying,
|
||||
vat_prc numeric(10,2) NOT NULL,
|
||||
vat_prc numeric(8,2) NOT NULL,
|
||||
paid_at timestamp without time zone,
|
||||
seller_id integer,
|
||||
seller_name character varying NOT NULL,
|
||||
|
@ -1024,7 +1034,7 @@ CREATE TABLE invoices (
|
|||
updator_str character varying,
|
||||
number integer,
|
||||
cancelled_at timestamp without time zone,
|
||||
sum_cache numeric(10,2)
|
||||
sum_cache numeric(8,2)
|
||||
);
|
||||
|
||||
|
||||
|
@ -2286,7 +2296,7 @@ CREATE TABLE pricelists (
|
|||
id integer NOT NULL,
|
||||
"desc" character varying,
|
||||
category character varying,
|
||||
price_cents numeric(8,2) DEFAULT 0 NOT NULL,
|
||||
price_cents numeric(8,2) DEFAULT 0.0 NOT NULL,
|
||||
price_currency character varying DEFAULT 'EUR'::character varying NOT NULL,
|
||||
valid_from timestamp without time zone,
|
||||
valid_to timestamp without time zone,
|
||||
|
@ -2550,7 +2560,7 @@ CREATE TABLE users (
|
|||
crt text,
|
||||
type character varying,
|
||||
registrant_ident character varying,
|
||||
encrypted_password character varying DEFAULT ''::character varying,
|
||||
encrypted_password character varying DEFAULT ''::character varying NOT NULL,
|
||||
remember_created_at timestamp without time zone,
|
||||
failed_attempts integer DEFAULT 0 NOT NULL,
|
||||
locked_at timestamp without time zone
|
||||
|
@ -4377,6 +4387,13 @@ CREATE INDEX index_whois_records_on_domain_id ON whois_records USING btree (doma
|
|||
CREATE INDEX index_whois_records_on_registrar_id ON whois_records USING btree (registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX unique_data_migrations ON data_migrations USING btree (version);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
@ -4592,8 +4609,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150227092508');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150227113121');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150302130224');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150302161712');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150303130729');
|
||||
|
@ -4652,8 +4667,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150417082723');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150421134820');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150422090645');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150422092514');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150422132631');
|
||||
|
@ -4698,8 +4711,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150519115050');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150519140853');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150519142542');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150519144118');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150520163237');
|
||||
|
@ -4708,12 +4719,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150520164507');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150521120145');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150522164020');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150525075550');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150603141054');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150603141549');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150603211318');
|
||||
|
@ -4728,3 +4733,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150610144547');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150611124920');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150612123111');
|
||||
|
||||
|
|
|
@ -224,6 +224,7 @@ namespace :import do
|
|||
legacy_id
|
||||
legacy_registrar_id
|
||||
legacy_registrant_id
|
||||
statuses
|
||||
)
|
||||
|
||||
domain_contact_columns = %w(
|
||||
|
@ -263,7 +264,7 @@ namespace :import do
|
|||
legacy_domain_id
|
||||
)
|
||||
|
||||
domains, nameservers, dnskeys, domain_statuses, domain_contacts = [], [], [], [], []
|
||||
domains, nameservers, dnskeys, domain_contacts = [], [], [], []
|
||||
existing_domain_ids = Domain.pluck(:legacy_id)
|
||||
user = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||
count = 0
|
||||
|
@ -281,6 +282,20 @@ namespace :import do
|
|||
count += 1
|
||||
|
||||
begin
|
||||
# domain statuses
|
||||
domain_statuses = []
|
||||
ok = true
|
||||
x.object_states.each do |state|
|
||||
next if state.name.blank?
|
||||
domain_statuses << state.name
|
||||
ok = false
|
||||
end
|
||||
|
||||
# OK status is default
|
||||
if ok
|
||||
domain_statuses << DomainStatus::OK
|
||||
end
|
||||
|
||||
domains << [
|
||||
x.object_registry.name.try(:strip),
|
||||
x.object_registry.try(:crdate),
|
||||
|
@ -296,7 +311,8 @@ namespace :import do
|
|||
user,
|
||||
x.id,
|
||||
x.object_registry.try(:crid),
|
||||
x.registrant
|
||||
x.registrant,
|
||||
domain_statuses
|
||||
]
|
||||
|
||||
# admin contacts
|
||||
|
@ -321,31 +337,6 @@ namespace :import do
|
|||
]
|
||||
end
|
||||
|
||||
# domain statuses
|
||||
ok = true
|
||||
x.object_states.each do |state|
|
||||
next if state.name.blank?
|
||||
domain_statuses << [
|
||||
state.desc,
|
||||
state.name,
|
||||
user,
|
||||
user,
|
||||
x.id
|
||||
]
|
||||
ok = false
|
||||
end
|
||||
|
||||
# OK status is default
|
||||
if ok
|
||||
domain_statuses << [
|
||||
nil,
|
||||
DomainStatus::OK,
|
||||
user,
|
||||
user,
|
||||
x.id
|
||||
]
|
||||
end
|
||||
|
||||
# nameservers
|
||||
x.nsset.hosts.each do |host|
|
||||
ip_maps = host.host_ipaddr_maps
|
||||
|
@ -384,9 +375,8 @@ namespace :import do
|
|||
Domain.import domain_columns, domains, validate: false
|
||||
Nameserver.import nameserver_columns, nameservers, validate: false
|
||||
Dnskey.import dnskey_columns, dnskeys, validate: false
|
||||
DomainStatus.import domain_status_columns, domain_statuses, validate: false
|
||||
DomainContact.import domain_contact_columns, domain_contacts, validate: false
|
||||
domains, nameservers, dnskeys, domain_statuses, domain_contacts = [], [], [], [], []
|
||||
domains, nameservers, dnskeys, domain_contacts = [], [], [], []
|
||||
end
|
||||
rescue => e
|
||||
puts "ERROR on index #{index}"
|
||||
|
@ -397,7 +387,6 @@ namespace :import do
|
|||
Domain.import domain_columns, domains, validate: false
|
||||
Nameserver.import nameserver_columns, nameservers, validate: false
|
||||
Dnskey.import dnskey_columns, dnskeys, validate: false
|
||||
DomainStatus.import domain_status_columns, domain_statuses, validate: false
|
||||
DomainContact.import domain_contact_columns, domain_contacts, validate: false
|
||||
|
||||
puts '-----> Updating relations...'
|
||||
|
@ -461,16 +450,6 @@ namespace :import do
|
|||
"AND domain_id IS NULL"
|
||||
)
|
||||
|
||||
# statuses
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE domain_statuses "\
|
||||
"SET domain_id = domains.id "\
|
||||
"FROM domains "\
|
||||
"WHERE domains.legacy_id = legacy_domain_id "\
|
||||
"AND legacy_domain_id IS NOT NULL "\
|
||||
"AND domain_id IS NULL"
|
||||
)
|
||||
|
||||
puts '-----> Generating dnskey digests...'
|
||||
|
||||
Dnskey.all.each do |x|
|
||||
|
|
|
@ -317,7 +317,7 @@ describe 'EPP Domain', epp: true do
|
|||
response = epp_plain_request(xml)
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
response[:result_code].should == '1000'
|
||||
Domain.first.valid_to.should be_within(5).of(1.year.since)
|
||||
Domain.first.valid_to.should be_within(60).of(1.year.since)
|
||||
end
|
||||
|
||||
it 'does not create a domain with invalid period' do
|
||||
|
@ -1501,7 +1501,8 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'should not allow any update when status pending update' do
|
||||
domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
|
||||
domain.statuses << DomainStatus::PENDING_UPDATE
|
||||
domain.save
|
||||
|
||||
existing_pw = domain.auth_info
|
||||
|
||||
|
@ -1592,11 +1593,10 @@ describe 'EPP Domain', epp: true do
|
|||
new_contact = d.tech_contacts.find_by(code: 'FIXED:MAK21')
|
||||
new_contact.should be_truthy
|
||||
|
||||
d.domain_statuses.count.should == 2
|
||||
d.domain_statuses.first.description.should == 'Payment overdue.'
|
||||
d.domain_statuses.first.value.should == 'clientHold'
|
||||
d.statuses.count.should == 2
|
||||
d.statuses.include?('clientHold').should == true
|
||||
d.statuses.include?('clientUpdateProhibited').should == true
|
||||
|
||||
d.domain_statuses.last.value.should == 'clientUpdateProhibited'
|
||||
d.dnskeys.count.should == 2
|
||||
|
||||
response = epp_plain_request(xml)
|
||||
|
@ -1621,39 +1621,39 @@ describe 'EPP Domain', epp: true do
|
|||
response[:results][2][:msg].should == 'Contact already exists on this domain [contact_code_cache]'
|
||||
response[:results][2][:value].should == 'FIXED:MAK21'
|
||||
|
||||
response[:results][3][:msg].should == 'Status already exists on this domain [value]'
|
||||
if response[:results][3][:value] == 'clientHold'
|
||||
response[:results][3][:value].should == 'clientHold'
|
||||
else
|
||||
response[:results][3][:value].should == 'clientUpdateProhibited'
|
||||
end
|
||||
# response[:results][3][:msg].should == 'Status already exists on this domain [value]'
|
||||
# if response[:results][3][:value] == 'clientHold'
|
||||
# response[:results][3][:value].should == 'clientHold'
|
||||
# else
|
||||
# response[:results][3][:value].should == 'clientUpdateProhibited'
|
||||
# end
|
||||
|
||||
response[:results][4][:msg].should == 'Status already exists on this domain [value]'
|
||||
if response[:results][4][:value] == 'clientHold'
|
||||
response[:results][4][:value].should == 'clientHold'
|
||||
else
|
||||
response[:results][4][:value].should == 'clientUpdateProhibited'
|
||||
end
|
||||
# response[:results][4][:msg].should == 'Status already exists on this domain [value]'
|
||||
# if response[:results][4][:value] == 'clientHold'
|
||||
# response[:results][4][:value].should == 'clientHold'
|
||||
# else
|
||||
# response[:results][4][:value].should == 'clientUpdateProhibited'
|
||||
# end
|
||||
|
||||
response[:results][5][:msg].should == 'Public key already exists [public_key]'
|
||||
if response[:results][5][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||
response[:results][5][:value].should ==
|
||||
response[:results][3][:msg].should == 'Public key already exists [public_key]'
|
||||
if response[:results][3][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||
response[:results][3][:value].should ==
|
||||
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||
else
|
||||
response[:results][5][:value].should ==
|
||||
response[:results][3][:value].should ==
|
||||
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
|
||||
end
|
||||
|
||||
response[:results][6][:msg].should == 'Public key already exists [public_key]'
|
||||
if response[:results][6][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||
response[:results][6][:value].should ==
|
||||
response[:results][4][:msg].should == 'Public key already exists [public_key]'
|
||||
if response[:results][4][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||
response[:results][4][:value].should ==
|
||||
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||
else
|
||||
response[:results][6][:value].should ==
|
||||
response[:results][4][:value].should ==
|
||||
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
|
||||
end
|
||||
|
||||
d.domain_statuses.count.should == 2
|
||||
d.statuses.count.should == 2
|
||||
end
|
||||
|
||||
it 'updates domain with registrant change what triggers action pending' do
|
||||
|
@ -1729,8 +1729,8 @@ describe 'EPP Domain', epp: true do
|
|||
new_contact = d.tech_contacts.find_by(code: 'FIXED:PENDINGMAK21')
|
||||
new_contact.should_not be_truthy # aka should not add new contact
|
||||
|
||||
d.domain_statuses.count.should == 1
|
||||
d.domain_statuses.first.value.should == 'pendingUpdate'
|
||||
d.statuses.count.should == 1
|
||||
d.statuses.first.should == 'pendingUpdate'
|
||||
|
||||
d.dnskeys.count.should == 0
|
||||
end
|
||||
|
@ -1840,10 +1840,11 @@ describe 'EPP Domain', epp: true do
|
|||
response[:results][0][:msg].should == 'Command completed successfully'
|
||||
response[:results][0][:result_code].should == '1000'
|
||||
|
||||
d.reload
|
||||
d.dnskeys.count.should == 1
|
||||
|
||||
d.domain_statuses.count.should == 1
|
||||
d.domain_statuses.first.value.should == 'clientUpdateProhibited'
|
||||
d.statuses.count.should == 1
|
||||
d.statuses.first.should == 'clientUpdateProhibited'
|
||||
|
||||
rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com')
|
||||
rem_ns.should be_falsey
|
||||
|
@ -1862,13 +1863,17 @@ describe 'EPP Domain', epp: true do
|
|||
response[:results][1][:value].should == 'FIXED:CITIZEN_1234'
|
||||
|
||||
response[:results][2][:result_code].should == '2303'
|
||||
response[:results][2][:msg].should == 'Status was not found'
|
||||
response[:results][2][:value].should == 'clientHold'
|
||||
response[:results][2][:msg].should == 'DS was not found'
|
||||
response[:results][2][:value].should == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
|
||||
|
||||
response[:results][3][:result_code].should == '2303'
|
||||
response[:results][3][:msg].should == 'Status was not found'
|
||||
response[:results][3][:value].should == 'clientHold'
|
||||
end
|
||||
|
||||
it 'does not remove server statuses' do
|
||||
d = Domain.last
|
||||
d.domain_statuses.create(value: DomainStatus::SERVER_HOLD)
|
||||
domain.statuses << DomainStatus::SERVER_HOLD
|
||||
domain.save
|
||||
|
||||
xml = domain_update_xml({
|
||||
name: { value: domain.name },
|
||||
|
@ -2079,9 +2084,10 @@ describe 'EPP Domain', epp: true do
|
|||
Domain.start_expire_period
|
||||
Domain.start_redemption_grace_period
|
||||
|
||||
domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1
|
||||
domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 1
|
||||
domain.domain_statuses.where(value: DomainStatus::OK).count.should == 0
|
||||
domain.reload
|
||||
domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
||||
domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true
|
||||
domain.statuses.include?(DomainStatus::OK).should == false
|
||||
|
||||
exp_date = domain.valid_to.to_date
|
||||
|
||||
|
@ -2095,9 +2101,10 @@ describe 'EPP Domain', epp: true do
|
|||
response[:results][0][:msg].should == 'Command completed successfully'
|
||||
response[:results][0][:result_code].should == '1000'
|
||||
|
||||
domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0
|
||||
domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0
|
||||
domain.domain_statuses.where(value: DomainStatus::OK).count.should == 1
|
||||
domain.reload
|
||||
domain.statuses.include?(DomainStatus::EXPIRED).should == false
|
||||
domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
domain.statuses.include?(DomainStatus::OK).should == true
|
||||
|
||||
domain.reload
|
||||
domain.valid_to.should be_within(5).of(new_valid_to)
|
||||
|
@ -2122,7 +2129,7 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
### INFO ###
|
||||
it 'returns domain info' do
|
||||
domain.domain_statuses.build(value: DomainStatus::CLIENT_HOLD, description: 'Payment overdue.')
|
||||
domain.statuses << DomainStatus::CLIENT_HOLD
|
||||
domain.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
|
||||
|
||||
domain.dnskeys.build(
|
||||
|
@ -2157,7 +2164,6 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
inf_data = response[:parsed].css('resData infData')
|
||||
inf_data.css('name').text.should == domain.name
|
||||
inf_data.css('status').text.should == 'Payment overdue.'
|
||||
inf_data.css('status').first[:s].should == 'clientHold'
|
||||
inf_data.css('registrant').text.should == domain.registrant_code
|
||||
inf_data.css('roid').text.should == domain.roid
|
||||
|
@ -2318,7 +2324,8 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'does not delete domain with specific status' do
|
||||
domain.domain_statuses.create(value: DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
domain.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
|
||||
domain.save
|
||||
|
||||
response = epp_plain_request(@epp_xml.domain.delete({
|
||||
name: { value: domain.name }
|
||||
|
@ -2336,7 +2343,8 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'does not delete domain with pending delete' do
|
||||
domain.domain_statuses.create(value: DomainStatus::PENDING_DELETE)
|
||||
domain.statuses << DomainStatus::PENDING_DELETE
|
||||
domain.save
|
||||
|
||||
response = epp_plain_request(@epp_xml.domain.delete({
|
||||
name: { value: domain.name }
|
||||
|
|
|
@ -22,11 +22,12 @@ feature 'DomainDeleteConfirm', type: :feature do
|
|||
context 'as unknown user with domain with token' do
|
||||
before :all do
|
||||
@domain = Fabricate(
|
||||
:domain,
|
||||
registrant_verification_token: '123',
|
||||
:domain,
|
||||
registrant_verification_token: '123',
|
||||
registrant_verification_asked_at: Time.zone.now
|
||||
)
|
||||
@domain.domain_statuses.create(value: DomainStatus::PENDING_DELETE)
|
||||
@domain.statuses << DomainStatus::PENDING_DELETE
|
||||
@domain.save
|
||||
end
|
||||
|
||||
it 'should see warning info if token is missing in request' do
|
||||
|
|
|
@ -22,11 +22,12 @@ feature 'DomainUpdateConfirm', type: :feature do
|
|||
context 'as unknown user with domain with update token' do
|
||||
before :all do
|
||||
@domain = Fabricate(
|
||||
:domain,
|
||||
registrant_verification_token: '123',
|
||||
:domain,
|
||||
registrant_verification_token: '123',
|
||||
registrant_verification_asked_at: Time.zone.now
|
||||
)
|
||||
@domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
|
||||
@domain.statuses << DomainStatus::PENDING_UPDATE
|
||||
@domain.save
|
||||
end
|
||||
|
||||
it 'should see warning info if token is missing in request' do
|
||||
|
|
|
@ -96,50 +96,60 @@ describe Domain do
|
|||
|
||||
it 'should expire domains' do
|
||||
Domain.start_expire_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0
|
||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == false
|
||||
|
||||
@domain.valid_to = Time.zone.now - 10.days
|
||||
@domain.save
|
||||
|
||||
Domain.start_expire_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
||||
|
||||
Domain.start_expire_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
||||
end
|
||||
|
||||
it 'should start redemption grace period' do
|
||||
Domain.start_redemption_grace_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
|
||||
@domain.outzone_at = Time.zone.now
|
||||
@domain.domain_statuses.create(value: DomainStatus::SERVER_MANUAL_INZONE) # this prohibits server_hold
|
||||
@domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold
|
||||
@domain.save
|
||||
|
||||
Domain.start_redemption_grace_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
|
||||
|
||||
@domain.domain_statuses.destroy_all
|
||||
@domain.statuses = []
|
||||
@domain.save
|
||||
|
||||
Domain.start_redemption_grace_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 1
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true
|
||||
end
|
||||
|
||||
it 'should start delete period' do
|
||||
Domain.start_delete_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 0
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == false
|
||||
|
||||
@domain.delete_at = Time.zone.now
|
||||
@domain.domain_statuses.create(value: DomainStatus::SERVER_DELETE_PROHIBITED) # this prohibits delete_candidate
|
||||
@domain.statuses << DomainStatus::SERVER_DELETE_PROHIBITED # this prohibits delete_candidate
|
||||
@domain.save
|
||||
|
||||
Domain.start_delete_period
|
||||
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 0
|
||||
@domain.reload
|
||||
@domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == false
|
||||
|
||||
@domain.domain_statuses.destroy_all
|
||||
@domain.statuses = []
|
||||
@domain.save
|
||||
Domain.start_delete_period
|
||||
@domain.reload
|
||||
|
||||
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 1
|
||||
@domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == true
|
||||
end
|
||||
|
||||
it 'should destroy delete candidates' do
|
||||
|
@ -159,15 +169,16 @@ describe Domain do
|
|||
end
|
||||
|
||||
it 'should set force delete time' do
|
||||
@domain.statuses = ['ok']
|
||||
@domain.set_force_delete
|
||||
|
||||
@domain.domain_statuses.count.should == 6
|
||||
fda = Time.zone.now + Setting.redemption_grace_period
|
||||
@domain.statuses.count.should == 6
|
||||
fda = Time.zone.now + Setting.redemption_grace_period.days
|
||||
@domain.force_delete_at.should be_within(20).of(fda)
|
||||
|
||||
@domain.unset_force_delete
|
||||
|
||||
@domain.domain_statuses.count.should == 1
|
||||
@domain.statuses.count.should == 1
|
||||
@domain.force_delete_at.should be_nil
|
||||
end
|
||||
|
||||
|
@ -175,7 +186,7 @@ describe Domain do
|
|||
before :all do
|
||||
@domain.registrant_verification_token = 123
|
||||
@domain.registrant_verification_asked_at = Time.zone.now
|
||||
@domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
|
||||
@domain.statuses << DomainStatus::PENDING_UPDATE
|
||||
end
|
||||
|
||||
it 'should be registrant update confirm ready' do
|
||||
|
@ -187,7 +198,7 @@ describe Domain do
|
|||
end
|
||||
|
||||
it 'should not be registrant update confirm ready when no correct status' do
|
||||
@domain.domain_statuses.delete_all
|
||||
@domain.statuses = []
|
||||
@domain.registrant_update_confirmable?('123').should == false
|
||||
end
|
||||
end
|
||||
|
@ -196,7 +207,7 @@ describe Domain do
|
|||
before :all do
|
||||
@domain.registrant_verification_token = 123
|
||||
@domain.registrant_verification_asked_at = Time.zone.now
|
||||
@domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
|
||||
@domain.statuses << DomainStatus::PENDING_UPDATE
|
||||
end
|
||||
|
||||
it 'should be registrant update confirm ready' do
|
||||
|
@ -208,7 +219,7 @@ describe Domain do
|
|||
end
|
||||
|
||||
it 'should not be registrant update confirm ready when no correct status' do
|
||||
@domain.domain_statuses.delete_all
|
||||
@domain.statuses = []
|
||||
@domain.registrant_update_confirmable?('123').should == false
|
||||
end
|
||||
end
|
||||
|
@ -441,24 +452,23 @@ describe Domain do
|
|||
|
||||
it 'manages statuses automatically' do
|
||||
d = Fabricate(:domain)
|
||||
expect(d.domain_statuses.count).to eq(1)
|
||||
expect(d.domain_statuses.first.value).to eq(DomainStatus::OK)
|
||||
expect(d.statuses.count).to eq(1)
|
||||
expect(d.statuses.first).to eq(DomainStatus::OK)
|
||||
|
||||
d.period = 2
|
||||
d.save
|
||||
|
||||
d.reload
|
||||
expect(d.statuses.count).to eq(1)
|
||||
expect(d.statuses.first).to eq(DomainStatus::OK)
|
||||
|
||||
expect(d.domain_statuses.count).to eq(1)
|
||||
expect(d.domain_statuses.first.reload.value).to eq(DomainStatus::OK)
|
||||
|
||||
d.domain_statuses.build(value: DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
d.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
|
||||
d.save
|
||||
|
||||
d.reload
|
||||
|
||||
expect(d.domain_statuses.count).to eq(1)
|
||||
expect(d.domain_statuses.first.value).to eq(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
expect(d.statuses.count).to eq(1)
|
||||
expect(d.statuses.first).to eq(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
end
|
||||
|
||||
with_versioning do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue